1.盘点单是做erp常用的一个功能,主要用来调整账上库存和实际库存不一致的情况。考虑到实际应用我们往往需要仓管事先盘点好后,批量导入到我们系统,所以这篇介绍几个导入界面的作法。
盘点单界面如下:
要求实现如下功能:
1.初始化界面的一些值。比如组织机构部门职员为当前登录用户的。币别默认为人民币汇率为1.
2。选物料后自动将物料品名规格带出来。(利用极致平台携带)
3.选择物料输入要盘点的仓库和单位后自动算出当前系统中记录的即时库存数量,人民币单价,金额,并反算出原币金额
4.输入实际数量自动算出调整数量。
5。考虑到实际盘点我们往往一次录入数据很多,让他支持excel快速导入,我们做两种导入方式。
导入方式1:
导入方式2
Excel数据源
(比较两种方式显然后者更方便,因为可以不用规定Excel的表头
6。盘点不允许同一物料出现2次,不然将调整两次肯定会出错。
7。审核的时候将调整数量反馈到即时库存表中。
当然我们一般做盘点都会选择所有影响库存变化的单据先进行审核了再盘点。
客户端代码如下:
/// <summary>
/// 盘点单基类
/// </summary>
class PandianBill : Jeez.MulEntityInput.BaseBillUI
{
//控件声明定义
private Jeez.Control.JeezUltraTextBox.JeezUltraTextBox txWLDW;//往来单位
private Jeez.Control.JeezUltraTextBox.JeezUltraTextBox txOrg;//组织机构
private Jeez.Control.JeezUltraTextBox.JeezUltraTextBox txDept;//部门
private Jeez.Control.JeezUltraTextBox.JeezUltraTextBox txEmployee;//业务员
private Jeez.Control.JeezUltraTextBox.JeezUltraTextBox txBibie;//币别
private Jeez.Control.JeezNumberTextBox.JeezNumberTextBox txRat;//汇率
private Jeez.Control.JeezCurrencyTextBox.JeezCurrencyTextBox txYBMoney;//原币金额
private Jeez.Control.JeezCurrencyTextBox.JeezCurrencyTextBox txRMBMoney;//人民币金额
private Jeez.Control.JeezUltraCalendarCombo.JeezUltraCalendarCombo dtDate;//日期
private Jeez.Control.JeezGrid.JeezGrid gridZY;//明细grid
private Jeez.Control.JeezUltraTabControl.JeezUltraTabControl pagecontrol1 = null;//下方页框控件
private Jeez.Control.JeezGrid.JeezGrid gridKucun;//库存
private bool isLoading = true;
//定义几个初始化常见的值
private static int BibieID = 0;//默认币别ID
private static int WLDWID = 0;//默认往来单位ID
private bool isSelect = true;//是否选单
public static int j = 0;//因为导入可能连续导入所以用来计数,而且还有可能
/// <summary>
/// 加载控件,以及控件相关事件定义
/// </summary>
/// <returns></returns>
public override bool LoadUI()
{
bool b = base.LoadUI();
if (b)
{
txWLDW = base.GetControlByName("JeezTextBox5") as Jeez.Control.JeezUltraTextBox.JeezUltraTextBox;
txOrg = base.GetControlByName("JeezTextBox3") as Jeez.Control.JeezUltraTextBox.JeezUltraTextBox;
txDept = base.GetControlByName("JeezTextBox4") as Jeez.Control.JeezUltraTextBox.JeezUltraTextBox;
txEmployee = base.GetControlByName("JeezTextBox6") as Jeez.Control.JeezUltraTextBox.JeezUltraTextBox;
txBibie = base.GetControlByName("JeezTextBox8") as Jeez.Control.JeezUltraTextBox.JeezUltraTextBox;
txRat = base.GetControlByName("JeezNumberTextBox1") as Jeez.Control.JeezNumberTextBox.JeezNumberTextBox;
txYBMoney = base.GetControlByName("JeezCurrencyTextBox1") as Jeez.Control.JeezCurrencyTextBox.JeezCurrencyTextBox;
txRMBMoney = base.GetControlByName("JeezCurrencyTextBox3") as Jeez.Control.JeezCurrencyTextBox.JeezCurrencyTextBox;
dtDate = base.GetControlByName("JeezCalendarCombo1") as Jeez.Control.JeezUltraCalendarCombo.JeezUltraCalendarCombo;
pagecontrol1 = base.GetControlByName("JeezTabControl1") as Jeez.Control.JeezUltraTabControl.JeezUltraTabControl;
gridZY = base.GetControlByName("JeezGrid1") as Jeez.Control.JeezGrid.JeezGrid;
gridKucun = base.GetControlByName("gridKucun") as Jeez.Control.JeezGrid.JeezGrid;
pagecontrol1.SelectedTabChanged += new Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventHandler(pagecontrol1_SelectedTabChanged);
txBibie.ValueChanged += new EventHandler(txBibie_ValueChanged);
txRat.TextChanged += new EventHandler(txRat_TextChanged);
gridZY.AfterCellUpdate += new CellEventHandler(gridZY_AfterCellUpdate);
}
return b;
}
protected override void InsertRow()
{
base.InsertRow();
j = 0;
foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in gridZY.Rows)
{
if (row.Cells["matid"].Value.ToString() != "")
{
j++;//为了插入分录后导入也正常
}
}
}
protected override void DeleteRow()
{
base.DeleteRow();
j = 0;
foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in gridZY.Rows)
{
if (row.Cells["matid"].Value.ToString() != "")
{
j++;//为了插入分录后导入也正常
}
}
}
/// <summary>
/// 更改Grid的构建方式
/// </summary>
/// <param name="CTL"></param>
/// <param name="EOL"></param>
/// <param name="IsDeleteChildEntity"></param>
protected override void FillGridDataToEntity(Jeez.ControlManager.ControlHelper CTL, EntityObjectList EOL, bool IsDeleteChildEntity)
{
base.FillGridDataToEntity(CTL, EOL, false);
}
/// <summary>
/// 设置默认值
/// </summary>
void InitByDefineOrder()
{
if (this.UIMainID == EntityFormIDEnum.仓库盘点单管理2)
{
if (!Jeez.Common.UI.AccessControl.CheckACLWithNoMsg(EntityRightIDEnum.盘点单查看价格))
{
this.gridZY.Rows.Band.Columns["Danjia"].Hidden = true;
this.gridZY.Rows.Band.Columns["Amount"].Hidden = true;
this.gridZY.Rows.Band.Columns["RDanjia"].Hidden = true;
this.gridZY.Rows.Band.Columns["RAmount"].Hidden = true;
txRMBMoney.Visible = false;
txYBMoney.Visible = false;
}
else
{
this.gridZY.Rows.Band.Columns["Danjia"].Hidden = false;
this.gridZY.Rows.Band.Columns["Amount"].Hidden = false;
this.gridZY.Rows.Band.Columns["RDanjia"].Hidden = false;
this.gridZY.Rows.Band.Columns["RAmount"].Hidden = false;
txRMBMoney.Visible = true;
txYBMoney.Visible = true;
}
}
}
/// <summary>
/// 计算当前库存
/// </summary>
/// <param name="matID"></param>
/// <returns></returns>
private EntityObject SetCurQtyEntityObject(Infragistics.Win.UltraWinGrid.UltraGridRow row)
{
string matID = row.Cells["MatID"].Value.ToString();
EntityObject cur = null;
EntityObject eoMat = base.GetRefEntityObjectByGridEntityCol(this.gridZY, row.Cells["MatID"]);
EntityObject eoUnit = base.GetRefEntityObjectByGridEntityCol(this.gridZY, row.Cells["jiliangdanweiID"]);
EntityObject eoWare = base.GetRefEntityObjectByGridEntityCol(this.gridZY, row.Cells["WareHouseID"]);
if (eoMat != null && eoUnit != null && eoWare != null)
{
EntityObjectFactory eof = EntityObjectFactory.GetInstance(this.objContext, EntityIDEnum.NowKucun);
EntityObject eo = eof.FindFirst("MatID={0} and WareHouseID={1} and jiliangdanweiID={2}", eoMat.GetProperty("ID"), eoWare.GetProperty("ID"), eoUnit.GetProperty("ID"));
if (eo != null)
{
cur = eo;
}
}
return cur;
}
/// <summary>
/// 页框轮换点击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void pagecontrol1_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e)
{
if (e.Tab.Index == 1)
{
//如果点的是第二个页框,用来显示即时库存
if (gridKucun != null)
{
StringBuilder strMatID = new StringBuilder();
strMatID.Append("(0");
foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in gridZY.Rows)
{
if (row.Cells["matid"].Value.ToString() != "")
{
//获取物料
EntityObject eoMat = base.GetRefEntityObjectByGridEntityCol(gridZY, row.Cells["matid"]);
strMatID.Append(string.Format(",{0}", (int)eoMat.PrimaryKeyValue));
}
}
strMatID.Append(")");
DataTable dt = new DataTable();
DataSet ds = new DataSet();
Jeez.Core.NativeQueryCommand cmd;
Jeez.Core.INativeQuery quary = Jeez.Login.RemoteCall.GetNativeQuery();
cmd = new NativeQueryCommand();
cmd.CommandText = string.Format(@"select b.Number as 物料代码,b.Name as 物料名称,c.Name as 计量单位,sum(a.Many) as 总数量,sum(a.UseMany) as 订单占用数量,sum(a.CUseMany) as 出库占用数量,sum(a.Many)-sum(a.CUseMany) as 可用数量 from jzNowKucun a left join jzMat b on a.MatID=b.ID
left join jzJiliangdanwei c on a.JiliangdanweiID=c.ID
where a.MatID in {0} group by b.Number,b.Name,c.Name", strMatID);
try
{
dt = quary.GetDataTable(this.objContext.ConnectionString, cmd);
ds = new System.Data.DataSet();
ds.Tables.Add(dt);
gridKucun.DataSource = ds.Tables[0];
gridKucun.FixCol = 3;
}
catch (Exception ex)
{
Jeez.Common.UI.MsgBox.Show(ex.Message.ToString());
}
}
}
}
/// <summary>
/// 设置菜单控件状态
/// </summary>
public override void SetMenuStatus()
{
base.SetMenuStatus();
}
/// <summary>
/// 保存前检查事件
/// </summary>
/// <returns></returns>
protected override bool BeforeSaveCheck()
{
bool b = base.BeforeSaveCheck();
if (b)
{
Hashtable hs = new Hashtable();
int i = 0;
foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in this.gridZY.Rows)
{
if (row.Cells["matid"].Value.ToString() != "")
{
if (!hs.Contains(row.Cells["MatID"].Value))
{
hs.Add(row.Cells["MatID"].Value, row.Cells["MatID"].Value);
}
i++;
}
}
if (hs.Count != i)
{
Jeez.Common.UI.MsgBox.Show("录入的物料有重复!");
return false;
}
CalAmount();
}
return b;
}
/// <summary>
/// 指定服务端调用的类
/// </summary>
/// <param name="ServerDllName"></param>
/// <param name="ServerClassName"></param>
protected override void SetInvokeBusiLogicName(out string ServerDllName, out string ServerClassName)
{
ServerDllName = "FolyerERPServer.dll";
ServerClassName = "FolyerERPServer.FolyerERPServer_SCM.PandianServer";
}
/// <summary>
/// 新增事件
/// </summary>
protected override void AddNew()
{
base.AddNew();
if (this.entityobject == null)
{
InitByDefine();
}
}
/// <summary>
/// 汇率手动调整后改变单价
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void txRat_TextChanged(object sender, EventArgs e)
{
if (!isLoading)
return;
//下推过程中以下推传过来的数据为主,不然会被冲掉
if (UserData != null)
return;
if (!isSelect)
return;
foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in this.gridZY.Rows)
{
if (row.Cells["matid"].Value.ToString() != "")
{
row.Cells["Danjia"].Value = Convert.ToDecimal(BaseFunc.IsNull(row.Cells["RDanjia"].Value, 0m)) / Convert.ToDecimal(BaseFunc.IsNull(txRat.PropertyPage.Value, 0m));
row.Cells["RAmount"].Value = Convert.ToDecimal(BaseFunc.IsNull(row.Cells["RDanjia"].Value, 0m)) / Convert.ToDecimal(BaseFunc.IsNull(txRat.PropertyPage.Value, 0m)) * Convert.ToDecimal(BaseFunc.IsNull(row.Cells["Many"].Value, 0m)); ;
}
}
}
/// <summary>
/// 币别变化事件,要自动算出该币别该单据的汇率,是固定汇率还是浮动汇率,还要调整子表的物料单价
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void txBibie_ValueChanged(object sender, EventArgs e)
{
if (!isLoading)
return;
//下推过程中以下推传过来的数据为主,不然会被冲掉
if (UserData != null)
return;
if (!isSelect)
return;
CalRat();
}
/// <summary>
/// 计算汇率
/// </summary>
void CalRat()
{
if ((int)txBibie.Tag != 0 && (int)txBibie.PropertyPage.Value.IndexOf("RMB") < 0 && txBibie.PropertyPage.Value.ToString() != "")
{ //如果不是人民币
if (dtDate.PropertyPage.Datetime == Jeez.Core.Toolkit.GetDateTimeDefaultValue())
{
Jeez.Common.UI.MsgBox.Show("请先输入单据日期,因为单据日期决定了币别汇率!");
return;
}
if (txOrg.Tag == null)
{
Jeez.Common.UI.MsgBox.Show("请先输入组织机构,因为汇率不同组织机构可能都有差异!");
return;
}
EntityObjectFactory eofBibi = EntityObjectFactory.GetInstance(objContext, EntityIDEnum.Currency);
EntityObject eoBibie = eofBibi.FindObject((int)txBibie.Tag);
if (eoBibie != null)
{
bool IsFixRat = (bool)eoBibie.GetProperty("IsFixRate");
if (IsFixRat)
{
//如果是固定汇率
EntityObjectList eolFixRat = eoBibie.GetChildEntityObjects(EntityIDEnum.FixedRate);
EntityObject eoFixRat = eolFixRat.FindFirst("Year={0} and Period={1} and OrganizationID={2}", (int)dtDate.PropertyPage.Datetime.Year, (int)dtDate.PropertyPage.Datetime.Month, (int)txOrg.Tag);
if (eoFixRat != null)
{
txRat.PropertyPage.Value = (decimal)eoFixRat.GetProperty("AccountBookRate");
}
else
{
Jeez.Common.UI.MsgBox.Show("请先在系统维护,基础资料,币别中输入该币别该期间的固定汇率");
return;
}
}
else
{
//如果是浮动汇率
EntityObjectList eolFixRat = eoBibie.GetChildEntityObjects(EntityIDEnum.FloatingRate);
EntityObject eoFixRat = eolFixRat.FindFirst("OrganizationID={0} and Date={1}", (int)txOrg.Tag, dtDate.PropertyPage.Datetime);
if (eoFixRat != null)
{
txRat.PropertyPage.Value = (decimal)eoFixRat.GetProperty("FloatRate");
}
else
{
Jeez.Common.UI.MsgBox.Show("请先在系统维护,基础资料,币别中输入该币别该期间的浮动汇率");
return;
}
}
}
}
else
{
txRat.PropertyPage.Value = 1.0m;
}
}
/// <summary>
/// 单元格值变化事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void gridZY_AfterCellUpdate(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
{
if (!isLoading)
return;
//下推过程中以下推传过来的数据为主,不然会被冲掉
if (UserData != null)
return;
if (!isSelect)
return;
if (e.Cell.Column.Key.ToLower() == "warehouseid" || e.Cell.Column.Key.ToLower() == "matid" || e.Cell.Column.Key.ToLower() == "many" || e.Cell.Column.Key.ToLower() == "jiliangdanweiid")
{
if (e.Cell.Row.Cells["MatID"].Value != null && e.Cell.Row.Cells["MatID"].Value != DBNull.Value && e.Cell.Row.Cells["MatID"].Value.ToString() != "")
{
EntityObject eoKucun = SetCurQtyEntityObject(e.Cell.Row);
if (eoKucun != null)
{
e.Cell.Row.Cells["ZMany"].Value = eoKucun.GetProperty("Many");//计算当前库存,从即时库存表中得来
e.Cell.Row.Cells["RDanjia"].Value = eoKucun.GetProperty("Danjia");//计算当前库存,从即时库存表中得来
}
}
}
if (e.Cell.Column.Key == "ZMany" || e.Cell.Column.Key == "SJMany")
{
foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in this.CurrentGrid.Rows)
{
if (row.Cells["MatID"].Value != null && row.Cells["MatID"].Value != DBNull.Value && row.Cells["MatID"].Value.ToString() != "")
{
row.Cells["Many"].Value = (decimal)BaseFunc.IsNull(row.Cells["SJMany"].Value, 0m) - (decimal)BaseFunc.IsNull(row.Cells["ZMany"].Value, 0m);
}
}
}
if (e.Cell.Column.Key.ToLower() == "rdanjia" || e.Cell.Column.Key.ToLower() == "many")
{
//计算子表的金额字段=单价*数量
e.Cell.Row.Cells["Amount"].Value = Convert.ToDecimal(BaseFunc.IsNull(e.Cell.Row.Cells["Danjia"].Value, 0m)) * Convert.ToDecimal(BaseFunc.IsNull(e.Cell.Row.Cells["Many"].Value, 0m));
e.Cell.Row.Cells["Danjia"].Value = Convert.ToDecimal(BaseFunc.IsNull(e.Cell.Row.Cells["RDanjia"].Value, 0m)) / Convert.ToDecimal(BaseFunc.IsNull(txRat.PropertyPage.Value, 0m));
e.Cell.Row.Cells["Amount"].Value = Convert.ToDecimal(BaseFunc.IsNull(e.Cell.Row.Cells["RDanjia"].Value, 0m)) / Convert.ToDecimal(BaseFunc.IsNull(txRat.PropertyPage.Value, 0m)) * Convert.ToDecimal(BaseFunc.IsNull(e.Cell.Row.Cells["Many"].Value, 0m)); ;
}
if (e.Cell.Column.Key.ToLower() == "amount")
{
//计算汇总将子表的金额合计汇总到父表
CalAmount();
}
}
/// <summary>
/// 自动计算价格汇总
/// </summary>
protected virtual void CalAmount()
{
decimal amount = 0;
if (txYBMoney != null && txRMBMoney != null)
{
foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in gridZY.Rows)
{
amount += Convert.ToDecimal(BaseFunc.IsNull(row.Cells["Amount"].Value, 0));
}
txYBMoney.PropertyPage.Value = amount;
txRMBMoney.PropertyPage.Value = amount * (decimal)txRat.PropertyPage.Value; ;
}
}
/// <summary>
/// 自动计算物料单价
/// </summary>
/// <param name="e"></param>
void CalMatPrice(Infragistics.Win.UltraWinGrid.CellEventArgs e)
{
if ((int)txBibie.Tag == 0)
{
Jeez.Common.UI.MsgBox.Show("请先输入币别!");
return;
}
if (txWLDW.Tag == null)
{
Jeez.Common.UI.MsgBox.Show("请先输入往来单位!");
return;
}
if (txWLDW.Tag != null && (int)txWLDW.Tag != 0 && txBibie.Tag != null && (int)txBibie.Tag != 0)
{
//获取物料
EntityObject eoMat = base.GetRefEntityObjectByGridEntityCol(gridZY, e.Cell.Row.Cells["matid"]);
//获取计量单位
EntityObject eoUnit = base.GetRefEntityObjectByGridEntityCol(gridZY, e.Cell.Row.Cells["jiliangdanweiid"]);
if (eoMat != null && eoUnit != null && Convert.ToDecimal(BaseFunc.IsNull(e.Cell.Row.Cells["Many"].Value, 0m)) > 0)
{
EntityObjectList eoChildList = eoMat.GetChildEntityObjects(EntityIDEnum.MatBuyPrice);
EntityObjectList eoChildl = eoChildList.Find("RefUnitID={0} and CurrencyID={1} and MinQty<={2} and JiliangdanweiID={3} and checkID=0", (int)txWLDW.Tag, (int)txBibie.Tag, Convert.ToDecimal(BaseFunc.IsNull(e.Cell.Row.Cells["Many"].Value, 0m)), (int)eoUnit.PrimaryKeyValue);
eoChildl.Sort("MinQty", SortDirection.Descending);
//如果存在销售价格记录
if (eoChildl.Count > 0)
{
EntityObject eoChild = eoChildl[0];
if (eoChild != null)
{
e.Cell.Row.Cells["Danjia"].Value = Convert.ToDecimal(BaseFunc.IsNull(eoChild.GetProperty("Danjia"), 0m));
}
else
{
Jeez.Common.UI.MsgBox.Show("物料采购价格表中还没有该物料价格,请先手动输入该物料本次价格,然后再保存单据后点击更新价格表!");
return;
}
}
else
{
//看公共往来单位是否存在销售价格记录
EntityObjectList eolChildPublic = eoChildList.Find("RefUnitID={0} and CurrencyID={1} and MinQty<={2} and JiliangdanweiID={3} and checkID=0", WLDWID, (int)txBibie.Tag, Convert.ToDecimal(BaseFunc.IsNull(e.Cell.Row.Cells["Many"].Value, 0m)), (int)eoUnit.PrimaryKeyValue);
eolChildPublic.Sort("MinQty", SortDirection.Descending);
if (eolChildPublic.Count > 0)
{
EntityObject eoChildPublic = eolChildPublic[0];
if (eoChildPublic != null)
{
e.Cell.Row.Cells["Danjia"].Value = Convert.ToDecimal(BaseFunc.IsNull(eoChildPublic.GetProperty("Danjia"), 0m));
}
}
else
{
Jeez.Common.UI.MsgBox.Show("物料采购价格表中还没有该物料价格,请先手动输入该物料本次价格,然后再保存单据后点击更新采购价格表!");
return;
}
}
}
}
}
/// <summary>
/// 弹出窗体事件,
/// </summary>
/// <param name="sender"></param>
/// <param name="EntityID"></param>
/// <param name="RunTimeFilter"></param>
protected override void ShowUISelectedForm(object sender, int EntityID, ArrayList RunTimeFilter)
{
//如果是往来单位表
if (EntityID == EntityIDEnum.RefUnit)
{
ArrayList ar = new ArrayList();
//过滤只有客户的往来单位
Jeez.Runtime.Base.General.RunTimefilterDefine fd;
fd = new Jeez.Runtime.Base.General.RunTimefilterDefine("{jzRefUnit.IsSupply}", 0, 0, Jeez.FormProperty.FilterDefineCompare.Equals, Jeez.FormProperty.FilterDefineLogic.NONE, 1);
ar.Add(fd);
base.ShowUISelectedForm(sender, EntityID, ar);
}
else
{
base.ShowUISelectedForm(sender, EntityID, RunTimeFilter);
}
}
protected override void BillUI_Load(object sender, EventArgs e)
{
base.BillUI_Load(sender, e);
if (this.entityobject == null)
{
//公共的初始化值
InitByDefine();
}
}
/// <summary>
/// 将实体数据banding到控件上的事件
/// </summary>
protected override void LoadEntityDataToControl()
{
isLoading = false;
base.LoadEntityDataToControl();
isLoading = true;
InitByDefineOrder();
}
/// <summary>
/// 自定义初始化控件上的一些值
/// </summary>
void InitByDefine()
{
//实现往来单位只能选择客户数据
txWLDW.AutoDropdownListFilter = string.Format("IsSupply=1");
//实现自动将当前登录用户所对应的职员信息的部门,组织机构,本身职员信息填充到界面上的三个控件减少输入
EntityObjectFactory eofEmployee = EntityObjectFactory.GetInstance(objContext, EntityIDEnum.Employee);
EntityObject eoEmp = eofEmployee.FindFirst("SysUserID={0}", Jeez.Login.Environment.UserID);
if (eoEmp != null && txEmployee != null)
{
txEmployee.Tag = eoEmp.PrimaryKeyValue;
txEmployee.VALUE = eoEmp.ToString();
txOrg.Tag = eoEmp.GetRelatedObject("OrganizationID").PrimaryKeyValue;
txOrg.VALUE = eoEmp.GetRelatedObject("OrganizationID").ToString();
txDept.Tag = eoEmp.GetRelatedObject("DepartMentID").PrimaryKeyValue;
txDept.VALUE = eoEmp.GetRelatedObject("DepartMentID").ToString();
}
//默认登录的时候币别为系统默认的币别
默认登录的时候往来单位ID获取
EntityObjectFactory eofInnit = EntityObjectFactory.GetInstance(objContext, EntityIDEnum.SystemInit);
EntityObject eoInit = eofInnit.FindFirst("ID>0");
EntityObject eoBibie = eoInit.GetRelatedObject("CurrencyID");
if (eoBibie != null)
{
txBibie.Tag = eoBibie.PrimaryKeyValue;
txBibie.VALUE = eoBibie.ToString();
txRat.PropertyPage.Value = 1.0m;
BibieID = (int)eoBibie.PrimaryKeyValue;
}
EntityObject eoWLDW = eoInit.GetRelatedObject("RefUnitID");
if (eoWLDW != null)
{
txWLDW.Tag = eoWLDW.PrimaryKeyValue;
txWLDW.VALUE = eoWLDW.ToString();
WLDWID = (int)eoWLDW.PrimaryKeyValue;
}
this.gridZY.RowCount = 5;//默认设置5行
}
/// <summary>
/// 菜单事件的扩展
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
/// <param name="Tool"></param>
public override void ResponseMenuToolClickEvent(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e, object Tool)
{
Jeez.FormProperty.JeezTool tool = Tool as Jeez.FormProperty.JeezTool;
if (tool == null) return;
this.Cursor = Jeez.Common.UI.Waitcursor.WaitCursor;
switch (tool.Name)
{
case "toolImport":
if (this.gridZY.ReadOnly)
return;
ExcelDataImport f = base.ShowForm(EntityFormIDEnum.数据导入窗口1) as ExcelDataImport;
f.Visible = false;
f.CallerForm = this;
f.ShowDialog();
break;
case "toolImport2":
if (this.gridZY.ReadOnly)
return;
ImportData();
break;
default:
break;
}
base.ResponseMenuToolClickEvent(sender, e, Tool);
this.Cursor = Jeez.Common.UI.Waitcursor.Default;
}
/// <summary>
/// 数据导入
/// </summary>
protected void ImportData()
{
try
{
ExcelDataImport2 frmImport = base.ShowForm(EntityFormIDEnum.数据导入窗口21) as ExcelDataImport2;
frmImport.Visible = false;
frmImport.ShowDialog();
if (frmImport.ImportOK)
{
string strMatID = frmImport.Fields[0].ToString();
string strWareHouseID = frmImport.Fields[1].ToString();
string strUnitID = frmImport.Fields[2].ToString();
string strSJMany = frmImport.Fields[3].ToString();
EntityObjectFactory eofMat = EntityObjectFactory.GetInstance(objContext, EntityIDEnum.Mat);
EntityObjectFactory eofWareHouse = EntityObjectFactory.GetInstance(objContext, EntityIDEnum.WareHouse);
EntityObjectFactory eofUnit = EntityObjectFactory.GetInstance(objContext, EntityIDEnum.jiliangdanwei);
System.Text.StringBuilder sb = new StringBuilder();
int i = 0;
//定义父表信息:
foreach (DataRow dr in frmImport.OuterData.Rows)
{
string strWareHouseIDValue = dr[strWareHouseID].ToString();
string strMatIDValue = dr[strMatID].ToString();
string strUnitIDValue = dr[strUnitID].ToString();
decimal strSJManyValue = decimal.Parse(dr[strSJMany].ToString());
EntityObject eoMat = eofMat.FindFirst("Number={0}", strMatIDValue);
EntityObject eoWareHouse = eofWareHouse.FindFirst("Number={0}", strWareHouseIDValue);
EntityObject eoUnit = eofUnit.FindFirst("Name={0}", strUnitIDValue);
if (eoMat == null)
{
sb.AppendLine(string.Format("第{0}行物料代码无效", i));
continue;
}
if (eoWareHouse == null)
{
sb.AppendLine(string.Format("第{0}行仓库代码无效", i));
continue;
}
if (eoUnit == null)
{
sb.AppendLine(string.Format("第{0}行计量单位名称无效", i));
continue;
}
//为子表赋值
gridZY.InsertRow(j);
gridZY.Rows[j].Cells["MatID"].Tag = eoMat.PrimaryKeyValue;
gridZY.Rows[j].Cells["MatID"].Value = eoMat.ToString();
gridZY.Rows[j].Cells["WareHouseID"].Tag = eoWareHouse.PrimaryKeyValue;
gridZY.Rows[j].Cells["WareHouseID"].Value = eoWareHouse.ToString();
gridZY.Rows[j].Cells["JiliangdanweiID"].Tag = eoUnit.PrimaryKeyValue;
gridZY.Rows[j].Cells["JiliangdanweiID"].Value = eoUnit.ToString();
gridZY.Rows[j].Cells["SJMany"].Value = strSJManyValue;
j++;
}
if (sb.Length > 0)
Jeez.Common.UI.FileIO.FileOperate.ShowLogFile("引入结果", sb.ToString());
}
}
catch (Exception ex)
{
Jeez.Common.UI.MsgBox.Show(ex.ToString());
}
}
/// <summary>
/// 将Excel数据赋值到Grid
/// </summary>
/// <param name="dt"></param>
internal void UpdateGridData(System.Data.DataTable dt)
{
try
{
if (dt == null)
return;
if (dt.Rows.Count == 0)
return;
//物料表
EntityObjectFactory eofmat = EntityObjectFactory.GetInstance(objContext, EntityIDEnum.Mat);
//仓库表
EntityObjectFactory eofWare = EntityObjectFactory.GetInstance(objContext, EntityIDEnum.WareHouse);
//计量单位表
EntityObjectFactory eofUnit = EntityObjectFactory.GetInstance(objContext, EntityIDEnum.jiliangdanwei);
System.Text.StringBuilder sb = new StringBuilder();
int i = 0;
//this.gridZY.DeleteAllRow();
//定义父表信息:
EntityObject eoRe;
foreach (DataRow r in dt.Rows)
{
i++;
//if (i == 1)
//{
// #region 检查excel数据源中父表信息
// **********判断货品是否ok***********//
// if (r["往来单位代码"].ToString().Trim() == "")
// {
// sb.AppendLine(string.Format("第{0}行往来单位代码资料不能为空", i));
// continue;
// }
// eoRe = eofRe.FindFirst("Number={0}", r["往来单位代码"].ToString());
// if (eoRe == null)
// {
// sb.AppendLine(string.Format("第{0}行往来单位代码无效", i));
// continue;
// }
// 为主表赋值
// if (eoRe != null)
// {
// txKH.Tag = eoRe.PrimaryKeyValue;
// txKH.VALUE = eoRe.ToString();
// }
// #endregion
//}
if (r["实际数量"].ToString() != "")
{
#region 检查excel子表数据源是否ok
//**********判断货品是否ok***********//
if (r["物料代码"].ToString().Trim() == "")
{
sb.AppendLine(string.Format("第{0}行物料代码资料不能为空", i));
continue;
}
EntityObject eomat = eofmat.FindFirst("Number={0}", r["物料代码"].ToString());
if (eomat == null)
{
sb.AppendLine(string.Format("第{0}行物料代码无效", i));
continue;
}
if (r["计量单位名称"].ToString().Trim() == "")
{
sb.AppendLine(string.Format("第{0}行计量单位名称无效", i));
continue;
}
EntityObject eounit = eofUnit.FindFirst("Name={0}", r["计量单位名称"].ToString());
if (eounit == null)
{
sb.AppendLine(string.Format("第{0}行单位名称无效", i));
continue;
}
if (r["仓库代码"].ToString().Trim() == "")
{
sb.AppendLine(string.Format("第{0}行仓库代码无效", i));
continue;
}
EntityObject eowarehouse = eofWare.FindFirst("Number={0}", r["仓库代码"].ToString());
if (eounit == null)
{
sb.AppendLine(string.Format("第{0}行仓库代码名称无效", i));
continue;
}
#endregion
decimal qty = 0m;
try
{
qty = Convert.ToDecimal(r["实际数量"]);
}
catch
{
sb.AppendLine(string.Format("第{0}行数量无效", i));
continue;
}
//为子表赋值
gridZY.InsertRow(j);
gridZY.Rows[j].Cells["MatID"].Tag = eomat.PrimaryKeyValue;
gridZY.Rows[j].Cells["MatID"].Value = eomat.ToString();
gridZY.Rows[j].Cells["WareHouseID"].Tag = eowarehouse.PrimaryKeyValue;
gridZY.Rows[j].Cells["WareHouseID"].Value = eowarehouse.ToString();
gridZY.Rows[j].Cells["JiliangdanweiID"].Tag = eounit.PrimaryKeyValue;
gridZY.Rows[j].Cells["JiliangdanweiID"].Value = eounit.ToString();
gridZY.Rows[j].Cells["SJMany"].Value = qty;
j++;
}
}
if (sb.Length > 0)
Jeez.Common.UI.FileIO.FileOperate.ShowLogFile("引入结果", sb.ToString());
}
catch (Exception ex)
{
Jeez.Common.UI.MsgBox.Show(ex.ToString());
}
}
}
两个导入导出通用界面后台代码
/// <summary>
/// 数据导入Excel类
/// </summary>
class ExcelDataImport : Jeez.Runtime.Base.General.GeneralUI
{
Jeez.Control.JeezUltraTextBox.JeezUltraTextBox txtFile;
Jeez.Control.UltraButton.JeezUltraButton btnOK;
Jeez.Control.UltraButton.JeezUltraButton btnCancel;
internal System.Data.DataTable dt;
public override bool LoadUI()
{
bool b = base.LoadUI();
if (b)
{
txtFile = base.GetControlByName("JeezTextBox1") as Jeez.Control.JeezUltraTextBox.JeezUltraTextBox;
btnCancel = base.GetControlByName("JeezButton2") as Jeez.Control.UltraButton.JeezUltraButton;
btnOK = base.GetControlByName("JeezButton1") as Jeez.Control.UltraButton.JeezUltraButton;
txtFile.EditorButtonClick += new Infragistics.Win.UltraWinEditors.EditorButtonEventHandler(txtFile_EditorButtonClick);
btnOK.Click += new EventHandler(btnOK_Click);
btnCancel.Click += new EventHandler(btnCancel_Click);
}
return b;
}
void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
protected bool CheckData(ref string strMsg)
{
if (dt == null)
{
strMsg = "请输入正确的文件";
return false;
}
return true;
}
void btnOK_Click(object sender, EventArgs e)
{
string str = string.Empty;
if (!this.CheckData(ref str))
{
Jeez.Common.UI.MsgBox.Inform(str);
}
else
{
base.Close();
PandianBill bill = base.CallerForm as PandianBill;
Jeez.Common.UI.MessageTip tip = new Jeez.Common.UI.MessageTip("正在导入数据,请稍等...");
try
{
bill.UpdateGridData(dt);
}
finally
{
tip.CloseMessageTip();
this.Close();
}
}
}
void txtFile_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
{
string FileName = Jeez.Common.UI.FileIO.FileOperate.GetOpenFileName("请选择数据源", "Microsoft Excel 文件(*.xls)|*.xls");
if (FileName.Length > 0)
{
DataSet ds = Jeez.Common.UI.ImportExport.FileImportExport.ExcelToDS(FileName);
if (ds == null)
{
this.txtFile.PropertyPage.Value = "";
}
else
{
this.txtFile.PropertyPage.Value = FileName;
dt = ds.Tables[0];
}
}
}
}
/// <summary>
/// 数据导入方式2调用的方法
/// </summary>
public class ExcelDataImport2 : Jeez.Runtime.Base.General.GeneralUI
{
private bool _ImportOK = false;
private DataTable _OuterData;
private ArrayList _Fields;
public bool ImportOK
{
get { return _ImportOK; }
}
public DataTable OuterData
{
get { return _OuterData; }
}
public ArrayList Fields
{
get { return _Fields; }
}
public Jeez.Control.JeezUltraTextBox.JeezUltraTextBox txtFile;
public Jeez.Control.UltraButton.JeezUltraButton btnOK;
public Jeez.Control.UltraButton.JeezUltraButton btnCancel;
public Jeez.Control.JeezUltraComboEditor.JeezUltraComboEditor cboMat;//物料
public Jeez.Control.JeezUltraComboEditor.JeezUltraComboEditor cboUnit;//单位
public Jeez.Control.JeezUltraComboEditor.JeezUltraComboEditor cboWareHouse;//仓库
public Jeez.Control.JeezUltraComboEditor.JeezUltraComboEditor cboSJMany;//实际数量
public override bool LoadUI()
{
bool b= base.LoadUI();
if (b)
{
txtFile = base.GetControlByName("JeezTextBox1") as Jeez.Control.JeezUltraTextBox.JeezUltraTextBox;
btnCancel = base.GetControlByName("JeezButton2") as Jeez.Control.UltraButton.JeezUltraButton;
btnOK = base.GetControlByName("JeezButton1") as Jeez.Control.UltraButton.JeezUltraButton;
cboMat = base.GetControlByName("JeezComboEditor1") as Jeez.Control.JeezUltraComboEditor.JeezUltraComboEditor;
cboWareHouse = base.GetControlByName("JeezComboEditor2") as Jeez.Control.JeezUltraComboEditor.JeezUltraComboEditor;
cboUnit = base.GetControlByName("JeezComboEditor3") as Jeez.Control.JeezUltraComboEditor.JeezUltraComboEditor;
cboSJMany = base.GetControlByName("JeezComboEditor4") as Jeez.Control.JeezUltraComboEditor.JeezUltraComboEditor;
txtFile.EditorButtonClick += new Infragistics.Win.UltraWinEditors.EditorButtonEventHandler(txtFile_EditorButtonClick);
btnOK.Click += new EventHandler(btnOK_Click);
btnCancel.Click += new EventHandler(btnCancel_Click);
}
return b;
}
protected override void GereralUI_Load(object sender, EventArgs e)
{
base.GereralUI_Load(sender, e);
}
private void txtFile_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
{ //this.Cursor = Jeez.Common.UI.Waitcursor.WaitCursor;
string FileName = Jeez.Common.UI.FileIO.FileOperate.GetOpenFileName("请选择数据源", "Microsoft Excel 文件(*.xls)|*.xls");
if (FileName.Length > 0)
{
cboMat.Items.Clear();
cboWareHouse.Items.Clear();
cboUnit.Items.Clear();
cboSJMany.Items.Clear();
DataSet ds = Jeez.Common.UI.ImportExport.FileImportExport.ExcelToDS(FileName);
if (ds == null)
{
this.txtFile.PropertyPage.Value = "";
}
else
{
this.txtFile.PropertyPage.Value = FileName;
_OuterData = ds.Tables[0];
foreach (DataColumn dc in _OuterData.Columns)
{
cboMat.Items.Add(dc.Caption);
cboWareHouse.Items.Add(dc.Caption);
cboUnit.Items.Add(dc.Caption);
cboSJMany.Items.Add(dc.Caption);
}
}
}
// this.Cursor = Jeez.Common.UI.Waitcursor.Default;
}
private void btnOK_Click(object sender, EventArgs e)
{
if ((cboMat.SelectedIndex < 0 && cboWareHouse.SelectedIndex < 0) || cboUnit.SelectedIndex < 0
|| cboSJMany.SelectedIndex < 0 )
{
Jeez.Common.UI.MsgBox.Show("请录入引入参数!");
return;
}
_Fields = new ArrayList(4);
_Fields.Add(cboMat.Text);
_Fields.Add(cboWareHouse.Text);
_Fields.Add(cboUnit.Text);
_Fields.Add(cboSJMany.Text);
_ImportOK = true;
this.Close();
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
}
服务端更改库存代码:
class PandianServer : SCMBaseServer
{
protected override bool CheckValidate(EntityObject eo, bool IsCheck, ref string strMessage)
{
bool b = base.CheckValidate(eo, IsCheck, ref strMessage);
if (b)
{
if (IsCheck)
{ //审核执行自己的业务逻辑
#region 更新即时库存表数据,浓缩成一个公共方法UpdateKucun
if (!ERPServerFunc.UpdateKucun(Context, eo, EntityIDEnum.PandianDetail, 0, ref strMessage))
return false;
#endregion
Context.SaveChanges();
}
else
{
//如果满足反审核条件,恢复库存
if (!ERPServerFunc.UpdateKucun(Context, eo, EntityIDEnum.PandianDetail, 1, ref strMessage))
return false;
Context.SaveChanges();
}
}
return b;
}
}
)
极致平台开发十大特点:
1. 一个数据库下可以同时进行N套业务系统开发,开发出来的产品可以根据您客户的需要按模块界面组发布,客户想要啥模块就可以给啥模块。而且一个数据库下开发所有功能,当客户需要从你的人力资源增加客户关系管理模块的时候,你只要做个升级包就可以了。解决企业多个业务系统信息孤岛问题。
2. 智能升级功能,当客户从A模块增加B模块的时候,您只需要做一个升级包即可,给客户升级后,客户原来录入的数据不会有影响,而且所有客户端都是智能感应智能升级,大大节省您的部署成本。
3. 工作流套打报表均可以运行时候自定义,比如费用报销单,您100家客户就有一百种费用报销的流程,套打的格式,用我们平台您只需要设计好这个费用报销单,至于哪个客户走什么流程,完全可以让客户自己去定义,而不需要像传统开发那样,提前在开发中设置好,100个客户就维护100套代码。套打也是如此。
4. 支持数据授权,当您开发多组织架构的系统的时候,我们只要业务单据引用组织机构即可,然后组织机构支持数据授权,这样就可以不需要编写任何一行代码就可以做到,组织与组织之间数据彼此隔离,我想给哪个用户看哪个组织的数据只要给这个用户这个组织的数据权限即可。
5. 支持字段授权,对于一些表的核心字段对用户进行屏蔽直接利用我们平台的字段授权功能即可,比如职员薪酬字段进行字段授权,让有的用户在看职员信息的时候,自动隐藏薪酬的数据。这也是无需编写任何一行代码。
6. 单据界面自动生成,我们开发的时候只要设计好实体,也就是传统开发所说的表结构即可,还可以设置哪些字段是必录,可见,不允许重复,在界面生成的时候,会自动生成一个界面,而且这个界面的增删改查是无需写一行代码的,您只要对您特有业务逻辑编码即可,相对传统开发,你代码量可以节省2/3,开发周期缩短2/3
7.一次开发同时具有单机局域互联网三个版本,客户想要单机就给单机想要互联网版就给互联网版。
8.强大的公式引擎,让您可以灵活设计计算类的项目,比如工资,预算。
9.包含强大的各种控件,比如文本控件支持F8调用,编码名称自动带出。Grid控件支持表头过滤,单元格融合,固定列,表格列,表格行各种公式汇总,复合表头,表格宽度可以自己随意调整,而且关闭后会自动记录之前的宽度。还支持表格列随意调整顺序。
10.平台内置很多基础功能,比如权限管理,用户角色管理,还有实施的一些导入导出工具都能帮助客户大大提高一个项目验收进度。
官网:www.jeez.com.cn
平台介绍:www.jeez.com.cn/jbf
平台下载地址:http://www.jeez.com.cn/upfiles/jbfsetuppro.rar
(下载即可有3个月免费试用)
联系电话:13826519021 18988763421 QQ:180315586 420977542 (加我注明极致软件即可)
平台销售经理:李先生
将互联网时代的管理软件做到极致!
==================================================================