public static BG_MonPayPlan AddBG_MonPayPlan(BG_MonPayPlan bG_MonPayPlan) { string sql = "INSERT BG_MonPayPlan (PIID, MPFunding, DeptID, MPTime, MPRemark, MPFundingAdd, MPFundingAddTimes)" + "VALUES (@PIID, @MPFunding, @DeptID, @MPTime, @MPRemark, @MPFundingAdd, @MPFundingAddTimes)"; sql += " ; SELECT @@IDENTITY"; try { SqlParameter[] para = new SqlParameter[] { new SqlParameter("@PIID", bG_MonPayPlan.PIID), new SqlParameter("@MPFunding", bG_MonPayPlan.MPFunding), new SqlParameter("@DeptID", bG_MonPayPlan.DeptID), new SqlParameter("@MPTime", bG_MonPayPlan.MPTime), new SqlParameter("@MPRemark", bG_MonPayPlan.MPRemark), new SqlParameter("@MPFundingAdd", bG_MonPayPlan.MPFundingAdd), new SqlParameter("@MPFundingAddTimes", bG_MonPayPlan.MPFundingAddTimes) }; string IdStr = DBUnity.ExecuteScalar(CommandType.Text, sql, para); int newId = Convert.ToInt32(IdStr); return GetBG_MonPayPlanByCPID(newId); } catch (Exception e) { Console.WriteLine(e.Message); throw e; } }
public static bool ModifyBG_MonPayPlan(BG_MonPayPlan bG_MonPayPlan) { return BG_MonPayPlanService.ModifyBG_MonPayPlan(bG_MonPayPlan); }
public static bool DeleteBG_MonPayPlan(BG_MonPayPlan bG_MonPayPlan) { return BG_MonPayPlanService.DeleteBG_MonPayPlan(bG_MonPayPlan); }
public static BG_MonPayPlan AddBG_MonPayPlan(BG_MonPayPlan bG_MonPayPlan) { return BG_MonPayPlanService.AddBG_MonPayPlan(bG_MonPayPlan); }
public static BG_MonPayPlan GetBG_MonPayPlanByCPID(int cPID) { string sql = "SELECT * FROM BG_MonPayPlan WHERE CPID = @CPID"; try { SqlParameter para = new SqlParameter("@CPID", cPID); DataTable dt = DBUnity.AdapterToTab(sql, para); if(dt.Rows.Count > 0) { BG_MonPayPlan bG_MonPayPlan = new BG_MonPayPlan(); bG_MonPayPlan.CPID = dt.Rows[0]["CPID"] == DBNull.Value ? 0 : (int)dt.Rows[0]["CPID"]; bG_MonPayPlan.PIID = dt.Rows[0]["PIID"] == DBNull.Value ? 0 : (int)dt.Rows[0]["PIID"]; bG_MonPayPlan.MPFunding = dt.Rows[0]["MPFunding"] == DBNull.Value ? 0 : (decimal)dt.Rows[0]["MPFunding"]; bG_MonPayPlan.DeptID = dt.Rows[0]["DeptID"] == DBNull.Value ? 0 : (int)dt.Rows[0]["DeptID"]; bG_MonPayPlan.MPTime = dt.Rows[0]["MPTime"] == DBNull.Value ? DateTime.MinValue : (DateTime)dt.Rows[0]["MPTime"]; bG_MonPayPlan.MPRemark = dt.Rows[0]["MPRemark"] == DBNull.Value ? "" : (string)dt.Rows[0]["MPRemark"]; bG_MonPayPlan.MPFundingAdd = dt.Rows[0]["MPFundingAdd"] == DBNull.Value ? 0 : (decimal)dt.Rows[0]["MPFundingAdd"]; bG_MonPayPlan.MPFundingAddTimes = dt.Rows[0]["MPFundingAddTimes"] == DBNull.Value ? 0 : (int)dt.Rows[0]["MPFundingAddTimes"]; return bG_MonPayPlan; } else { return null; } } catch (Exception e) { Console.WriteLine(e.Message); throw e; } }
public static bool DeleteBG_MonPayPlan(BG_MonPayPlan bG_MonPayPlan) { return DeleteBG_MonPayPlanByCPID( bG_MonPayPlan.CPID ); }
public static bool ModifyBG_MonPayPlan(BG_MonPayPlan bG_MonPayPlan) { string sql = "UPDATE BG_MonPayPlan " + "SET " + "PIID = @PIID, " + "MPFunding = @MPFunding, " + "DeptID = @DeptID, " + "MPTime = @MPTime, " + "MPRemark = @MPRemark, " + "MPFundingAdd = @MPFundingAdd, " + "MPFundingAddTimes = @MPFundingAddTimes " + "WHERE CPID = @CPID"; try { SqlParameter[] para = new SqlParameter[] { new SqlParameter("@CPID", bG_MonPayPlan.CPID), new SqlParameter("@PIID", bG_MonPayPlan.PIID), new SqlParameter("@MPFunding", bG_MonPayPlan.MPFunding), new SqlParameter("@DeptID", bG_MonPayPlan.DeptID), new SqlParameter("@MPTime", bG_MonPayPlan.MPTime), new SqlParameter("@MPRemark", bG_MonPayPlan.MPRemark), new SqlParameter("@MPFundingAdd", bG_MonPayPlan.MPFundingAdd), new SqlParameter("@MPFundingAddTimes", bG_MonPayPlan.MPFundingAddTimes) }; int t = DBUnity.ExecuteNonQuery(CommandType.Text, sql, para); if(t>0) { return true; } else { return false; } } catch (Exception e) { Console.WriteLine(e.Message); throw e; } }
protected void RemoteEdit(object sender, RemoteEditEventArgs e) { string pici = cmbpici.SelectedItem.Value; string pici1 = cmbpici.RawValue.ToString(); string pici2 = cmbpici.SelectedItem.Text; pici = pici1 == pici2 ? pici1 : pici2; string yearMonth = CurrentYear + "-" + cmbmon.SelectedItem.Value; if (hidflag.Text == "1") { X.Msg.Alert("申请月度用款计划", yearMonth + "月已经提交,不允许修改").Show(); return; } if (hidflag.Text == "4") { X.Msg.Alert("申请月度用款计划", "本月未审核通过,不允许为下月申请预算").Show(); return; } if (hidflag.Text == "5") { X.Msg.Alert("申请月度用款计划", "该退回申请已无效").Show(); return; } e.Accept = true; string[] idStrArr = HidSlist.Text.ToString().TrimEnd('&').Split('&'); List<int> slist = new List<int>(); foreach (string item in idStrArr) { int IntId = common.IntSafeConvert(item); if (!slist.Contains(IntId)) { slist.Add(IntId); } } int piid = common.IntSafeConvert(e.NodeID); RowChanges rc = e.Changes[0]; //if (rc.Value<float>() <= 0 && rc.OldValue<float>() <= 0) //{ // X.Msg.Alert("提示", "填写数字不能为0").Show(); // return; //} if (e.Json == null) { return; } if (!slist.Contains(piid)) { rc.SetValue(""); X.Msg.Alert("提示", "此处不可填写,请填写到正确位置").Show(); return; } else { decimal newValue = 0; decimal oldValue = 0; decimal balance = 0; decimal MPFundingAdd = 0; decimal Mon = 0; DataTable dt = BG_MonPayPlanLogic.GetMpFunding(piid, DepID, yearMonth, common.IntSafeConvert(pici)); if (rc.Field == "MPRemark") { if (!rc.IsDirty<string>()) { return; } if (dt.Rows.Count > 0) { int CPID = common.IntSafeConvert(dt.Rows[0][0]); BG_MonPayPlan mp = BG_MonPayPlanManager.GetBG_MonPayPlanByCPID(CPID); mp.MPRemark = rc.Value<string>(); BG_MonPayPlanManager.ModifyBG_MonPayPlan(mp); } else { BG_MonPayPlan mp = new BG_MonPayPlan(); mp.MPRemark = rc.Value<string>(); mp.DeptID = DepID; mp.PIID = piid; mp.MPFundingAdd = 0; mp.MPTime = Convert.ToDateTime(CurrentYear + "-" + cmbmon.SelectedItem.Value + "-01"); BG_MonPayPlanManager.AddBG_MonPayPlan(mp); } return; } DataTable dtdevide = BG_MonPayPlanGenerateLogic.GetMonPay(common.IntSafeConvert(CurrentYear), DepID); string PIEcoSubName = ""; PIEcoSubName = BG_PayIncomeManager.GetBG_PayIncomeByPIID(piid).PIEcoSubName; string sql = string.Format("PIEcoSubName='{0}'", PIEcoSubName); DataRow[] drdevide = dtdevide.Select(sql); if (drdevide.Length > 0) { for (int i = 0; i < drdevide.Length; i++) { Mon += ParToDecimal.ParToDel(drdevide[i]["BAAMon"].ToString()) + ParToDecimal.ParToDel(drdevide[i]["SuppMon"].ToString()); } } sql = string.Format("PIID={0}", piid); DataRow[] dr = dt.Select(sql); if (dr.Length > 0) { for (int i = 0; i < dr.Length; i++) { MPFundingAdd += ParToDecimal.ParToDel(dr[i]["MPFundingAdd"].ToString()); } } newValue = ParseUtil.ToDecimal(rc.Value<float>().ToString(), 0); oldValue = ParseUtil.ToDecimal(rc.OldValue<float>().ToString(), 0); //if (newValue==0) //{ // BG_MonPayPlan mppalert = new BG_MonPayPlan(); // mppalert = BG_MonPayPlanManager.GetBG_MonPayPlanByCPID(CPID); // mppalert.MPFundingAdd = newValue / 10000; // mppalert.MPFunding = mppalert.MPFunding + (newValue) / 10000 - oldValue / 10000; // mppalert.MPFundingAddTimes = common.IntSafeConvert(cmbpici.SelectedItem.Value); // BG_MonPayPlanManager.ModifyBG_MonPayPlan(mppalert); // string message = "<b>科目:</b> {0}<br /><b>原经费:</b> {1}<br /><b>更改经费:</b> {2}"; // X.Msg.Notify(new NotificationConfig() // { // Title = "申请月度用款计划", // Html = string.Format(message, PIEcoSubName, oldValue, newValue), // Width = 250 // }).Show(); // return; //} balance = Mon - MPFundingAdd; if (dt.Rows.Count > 0) { int CPID = common.IntSafeConvert(dt.Rows[0][0]); BG_MonPayPlan mp = BG_MonPayPlanManager.GetBG_MonPayPlanByCPID(CPID); foreach (RowChanges change in e.Changes) { if (change.Field == "MPFundingAdd" && change.IsDirty<float>()) { if (mp.MPFunding + newValue > Mon * 10000) { X.Msg.Alert("申请月度用款计划", "科目:" + PIEcoSubName + "经费不足,请调整经费").Show(); return; } mp.MPFundingAdd = newValue; if (hidflag.Text == "2" || hidflag.Text == "3") { string message = "<b>科目:</b> {0}<br /><b>原经费:</b> {1}<br /><b>更改经费:</b> {2}"; //if (oldValue > newValue) //{ // //X.Msg.Alert("提示", "修改提交或审核通过的经费必须大于现经费").Show(); // //rc.SetValue(rc.OldValue<float>()); // //return; //} //else //{ BG_MonPayPlan mppalert = new BG_MonPayPlan(); mppalert = BG_MonPayPlanManager.GetBG_MonPayPlanByCPID(CPID); mppalert.MPFundingAdd = newValue / 10000; mppalert.MPFunding = mppalert.MPFunding + (newValue) / 10000 - oldValue / 10000; mppalert.MPFundingAddTimes = common.IntSafeConvert(cmbpici.SelectedItem.Value); BG_MonPayPlanManager.ModifyBG_MonPayPlan(mppalert); // BG_MonPayPlan_His bgMonPayPlanHis = new BG_MonPayPlan_His(); // bgMonPayPlanHis.CPID = CPID; // bgMonPayPlanHis.DeptID = mppalert.DeptID; // bgMonPayPlanHis.MPFunding = mppalert.MPFunding; // bgMonPayPlanHis.MPPHisTime = DateTime.Now; // bgMonPayPlanHis.PIID = mppalert.PIID; // bgMonPayPlanHis.MPRemark = "修改"; // bgMonPayPlanHis.MPFundingAdd = mppalert.MPFundingAdd; // bgMonPayPlanHis.MPTime = mppalert.MPTime; // bgMonPayPlanHis.MPFundingAddTimes = mppalert.MPFundingAddTimes; // if (BG_MonPayPlan_HisManager.AddBG_MonPayPlan_His(bgMonPayPlanHis).MPPHis > 0) // { // GetGridPaneltotal(); // } X.Msg.Notify(new NotificationConfig() { Title = "申请月度用款计划", Html = string.Format(message, PIEcoSubName, oldValue, newValue), Width = 250 }).Show(); //return; //} } else if (hidflag.Text == "1") { X.Msg.Alert("申请月度用款计划", yearMonth + "月已经提交,不允许修改").Show(); rc.SetValue(rc.OldValue<float>()); return; } else if (hidflag.Text == "0") { string message = "<b>科目:</b> {0}<br /><b>原经费:</b> {1}<br /><b>更改经费:</b> {2}"; BG_MonPayPlan mpp = new BG_MonPayPlan(); mpp = BG_MonPayPlanManager.GetBG_MonPayPlanByCPID(CPID); if (mpp != null) { mpp.MPFundingAdd = newValue / 10000; mpp.MPFunding = mpp.MPFunding + (newValue) / 10000 - oldValue / 10000; mpp.MPFundingAddTimes = common.IntSafeConvert(cmbpici.SelectedItem.Value); BG_MonPayPlanManager.ModifyBG_MonPayPlan(mpp); // if (mpp.CPID > 0) // { // BG_MonPayPlan_His bgMonPayPlanHis = new BG_MonPayPlan_His(); // bgMonPayPlanHis.CPID = mpp.CPID; // bgMonPayPlanHis.DeptID = mpp.DeptID; // bgMonPayPlanHis.MPFunding = mpp.MPFunding; // bgMonPayPlanHis.MPPHisTime = DateTime.Now; // bgMonPayPlanHis.PIID = mpp.PIID; // bgMonPayPlanHis.MPRemark = "修改"; // bgMonPayPlanHis.MPFundingAdd = mpp.MPFundingAdd; // bgMonPayPlanHis.MPTime = mpp.MPTime; // bgMonPayPlanHis.MPFundingAddTimes = mpp.MPFundingAddTimes; // if (BG_MonPayPlan_HisManager.AddBG_MonPayPlan_His(bgMonPayPlanHis).MPPHis > 0) // { // GetGridPaneltotal(); // } // } X.Msg.Notify(new NotificationConfig() { Title = "申请月度用款计划", Html = string.Format(message, PIEcoSubName, oldValue, newValue), Width = 250 }).Show(); } else { mpp.MPRemark = ""; mpp.DeptID = DepID; mpp.PIID = piid; mpp.MPFundingAdd = newValue / 10000; mpp.MPFunding += newValue / 10000; mpp.MPTime = Convert.ToDateTime(CurrentYear + "-" + cmbmon.SelectedItem.Value + "-01"); mpp.MPFundingAddTimes = common.IntSafeConvert(cmbpici.SelectedItem.Value); BG_MonPayPlanManager.AddBG_MonPayPlan(mpp); // int cpid = BG_MonPayPlanManager.AddBG_MonPayPlan(mpp).CPID; // if (cpid > 0) // { // BG_MonPayPlan_His bgMonPayPlanHis = new BG_MonPayPlan_His(); // bgMonPayPlanHis.CPID = cpid; // bgMonPayPlanHis.DeptID = mpp.DeptID; // bgMonPayPlanHis.MPFunding = mpp.MPFunding; // bgMonPayPlanHis.MPPHisTime = DateTime.Now; // bgMonPayPlanHis.PIID = mpp.PIID; // bgMonPayPlanHis.MPRemark = "添加"; // bgMonPayPlanHis.MPFundingAdd = mpp.MPFundingAdd; // bgMonPayPlanHis.MPTime = mpp.MPTime; // bgMonPayPlanHis.MPFundingAddTimes = mpp.MPFundingAddTimes; // if (BG_MonPayPlan_HisManager.AddBG_MonPayPlan_His(bgMonPayPlanHis).MPPHis > 0) // { // GetGridPaneltotal(); // } // } X.Msg.Notify(new NotificationConfig() { Title = "申请月度用款计划", Html = string.Format(message, PIEcoSubName, oldValue, newValue), Width = 250 }).Show(); } } } } } else { if (newValue > Mon * 10000) { X.Msg.Alert("申请月度用款计划", "科目:" + PIEcoSubName + "经费不足,请调整经费").Show(); return; } string message = "<b>科目:</b> {0}<br /><b>原经费:</b> {1}<br /><b>更改经费:</b> {2}"; BG_MonPayPlan mpp = new BG_MonPayPlan(); mpp.DeptID = DepID; mpp.PIID = piid; mpp.MPFundingAdd = newValue / 10000; mpp.MPFunding += newValue / 10000; mpp.MPTime = Convert.ToDateTime(CurrentYear + "-" + cmbmon.SelectedItem.Value + "-01"); mpp.MPFundingAddTimes = 1; mpp.MPFundingAddTimes = common.IntSafeConvert(cmbpici.SelectedItem.Value); BG_MonPayPlanManager.AddBG_MonPayPlan(mpp); // int cpid = BG_MonPayPlanManager.AddBG_MonPayPlan(mpp).CPID; // if (cpid > 0) // { // BG_MonPayPlan_His bgMonPayPlanHis = new BG_MonPayPlan_His(); // bgMonPayPlanHis.CPID = cpid; // bgMonPayPlanHis.DeptID = mpp.DeptID; // bgMonPayPlanHis.MPFunding = mpp.MPFunding; // bgMonPayPlanHis.MPPHisTime = DateTime.Now; // bgMonPayPlanHis.PIID = mpp.PIID; // bgMonPayPlanHis.MPRemark = "添加"; // bgMonPayPlanHis.MPFundingAdd = mpp.MPFundingAdd; // bgMonPayPlanHis.MPTime = mpp.MPTime; // bgMonPayPlanHis.MPFundingAddTimes = mpp.MPFundingAddTimes; // if (BG_MonPayPlan_HisManager.AddBG_MonPayPlan_His(bgMonPayPlanHis).MPPHis > 0) // { // GetGridPaneltotal(); // } // // } hidflag.Text = "2"; X.Msg.Notify(new NotificationConfig() { Title = "申请月度用款计划", Html = string.Format(message, PIEcoSubName, oldValue, newValue), Width = 250 }).Show(); } } gettotal(); TPPlan.Listeners.AddScript("GettatolMon();"); }