/// <summary> /// 向表格添加数据 /// </summary> /// <param name="alAddRate"></param> protected virtual void AddDataToFp(ArrayList alAddRate) { if (alAddRate != null && alAddRate.Count > 0) { foreach (Neusoft.HISFC.Models.Material.MaterialAddRate obj in alAddRate) { ArrayList alMatKind = new ArrayList(); Neusoft.HISFC.Models.Material.MaterialKind matKind = new Neusoft.HISFC.Models.Material.MaterialKind(); alMatKind = this.addRateManager.QueryKindAllByID(obj.MaterialKind.ID); if (alMatKind.Count > 0) { matKind = alMatKind[0] as Neusoft.HISFC.Models.Material.MaterialKind; } int row = this.FpAddRate_Sheet1.RowCount; this.FpAddRate_Sheet1.Rows.Add(row, 1); this.FpAddRate_Sheet1.Cells[row, 1].Text = obj.ID; this.FpAddRate_Sheet1.Cells[row, 2].Text = obj.RateKind.Name; this.FpAddRate_Sheet1.Cells[row, 3].Text = obj.Specs; this.FpAddRate_Sheet1.Cells[row, 4].Text = obj.PriceLow.ToString(); this.FpAddRate_Sheet1.Cells[row, 5].Text = obj.PriceHigh.ToString(); this.FpAddRate_Sheet1.Cells[row, 6].Text = obj.AddRate.ToString(); this.FpAddRate_Sheet1.Cells[row, 7].Text = obj.AppendFee.ToString(); this.FpAddRate_Sheet1.Cells[row, 8].Text = obj.Oper.ID; this.FpAddRate_Sheet1.Cells[row, 9].Value = obj.OperDate; this.FpAddRate_Sheet1.Cells[row, 10].Text = matKind.Name; this.FpAddRate_Sheet1.Cells[row, 10].Tag = obj.MaterialKind.ID; this.FpAddRate_Sheet1.Rows[row].Tag = obj; } } }
/// <summary> /// 保存数据{BAF240DB-D9B6-480b-978A-9BDC019A46E8} /// </summary> public int Save(bool isTempSave) { this.selectedNode = this.ucMaterialKindTree1.neuTreeView1.SelectedNode.Tag.ToString(); this.neuSpread1.StopCellEditing(); //有效性判断 if (this.Valid()) { return(-1); } ; foreach (DataRow dr in this.dt.Rows) { dr.EndEdit(); } this.SetLeafFlag(); //定义数据库处理事务 Neusoft.FrameWork.Management.PublicTrans.BeginTransaction(); //Neusoft.FrameWork.Management.Transaction t = new Neusoft.FrameWork.Management.Transaction(Neusoft.FrameWork.Management.Connection.Instance); //t.BeginTransaction(); basesetManager.SetTrans(Neusoft.FrameWork.Management.PublicTrans.Trans); bool isUpdate = false; //判断是否更新或者删除过数据 DateTime sysTime = this.basesetManager.GetDateTimeFromSysDateTime(); //取修改和增加的数据 DataTable dataChanges = this.dt.GetChanges(DataRowState.Modified | DataRowState.Added); if (dataChanges != null) { foreach (DataRow row in dataChanges.Rows) { Neusoft.HISFC.Models.Material.MaterialKind metKind = new Neusoft.HISFC.Models.Material.MaterialKind(); #region 根据本次输入信息进行科目信息赋值 //科目级别 metKind.Kgrade = row["科目级别"].ToString(); //科目编码 metKind.ID = row["科目编码"].ToString(); //上级编码 metKind.SuperKind = row["上级编码"].ToString(); //科目名称 metKind.Name = row["科目名称"].ToString(); //拼音码 metKind.SpellCode = row["拼音码"].ToString(); //五笔码 metKind.WBCode = row["五笔码"].ToString(); //最末级标识 metKind.EndGrade = Neusoft.FrameWork.Function.NConvert.ToBoolean(row["末级标识"].ToString()); //需要卡片 metKind.IsCardNeed = Neusoft.FrameWork.Function.NConvert.ToBoolean(row["需要卡片"].ToString()); //批次管理 metKind.IsBatch = Neusoft.FrameWork.Function.NConvert.ToBoolean(row["批次管理"].ToString()); //有效期管理 metKind.IsValidcon = Neusoft.FrameWork.Function.NConvert.ToBoolean(row["效期管理"].ToString()); //财务科目编码 metKind.AccountCode.ID = row["财务科目编码"].ToString(); //财务科目名称 metKind.AccountName.Name = row["财务科目名称"].ToString(); //预计残值率 metKind.LeftRate = Neusoft.FrameWork.Function.NConvert.ToDecimal(row["预计残值率"].ToString()); //是否固定资产 metKind.IsFixedAssets = Neusoft.FrameWork.Function.NConvert.ToBoolean(row["固定资产"].ToString()); //排列序号 metKind.OrderNo = Neusoft.FrameWork.Function.NConvert.ToInt32(row["排列序号"].ToString()); //对应成本核算项目类别 metKind.StatCode = row["核算类别"].ToString(); //是否加价卫材 metKind.IsAddFlag = Neusoft.FrameWork.Function.NConvert.ToBoolean(row["加价卫材"].ToString()); #endregion metKind.Oper.ID = this.basesetManager.Operator.ID; metKind.Oper.OperTime = sysTime; //执行更新操作,先更新,如果没有成功则插入新数据 if (this.basesetManager.SetKind(metKind) == -1) { Neusoft.FrameWork.Management.PublicTrans.RollBack(); MessageBox.Show(this.basesetManager.Err); return(0); } } dataChanges.AcceptChanges(); isUpdate = true; } Neusoft.FrameWork.Management.PublicTrans.Commit(); //刷新数据 if (!isTempSave) { this.ShowData(); MessageBox.Show("保存成功!"); } return(1); }