/// <summary> /// get all accperiodlist /// <summary> /// <param name=accyear>accyear</param> /// <param name=out emsg>return error message</param> ///<returns>details of all accperiodlist</returns> public BindingCollection <modAccPeriodList> GetIList(out string emsg) { try { BindingCollection <modAccPeriodList> modellist = new BindingCollection <modAccPeriodList>(); //Execute a query to read the categories string sql = "select acc_name,seq,acc_year,acc_month,start_date,end_date,cost_flag,lock_flag,employee_count,update_user,update_time from acc_period_list order by seq desc"; using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql)) { while (rdr.Read()) { modAccPeriodList model = new modAccPeriodList(); model.AccName = dalUtility.ConvertToString(rdr["acc_name"]); model.Seq = dalUtility.ConvertToInt(rdr["seq"]); model.AccYear = dalUtility.ConvertToInt(rdr["acc_year"]); model.AccMonth = dalUtility.ConvertToInt(rdr["acc_month"]); model.StartDate = dalUtility.ConvertToDateTime(rdr["start_date"]); model.EndDate = dalUtility.ConvertToDateTime(rdr["end_date"]); model.CostFlag = dalUtility.ConvertToInt(rdr["cost_flag"]); model.LockFlag = dalUtility.ConvertToInt(rdr["lock_flag"]); model.EmployeeCount = dalUtility.ConvertToInt(rdr["employee_count"]); model.UpdateUser = dalUtility.ConvertToString(rdr["update_user"]); model.UpdateTime = dalUtility.ConvertToDateTime(rdr["update_time"]); modellist.Add(model); } } emsg = null; return(modellist); } catch (Exception ex) { emsg = dalUtility.ErrorMessage(ex.Message); return(null); } }
private void LoadData() { try { this.Cursor = Cursors.WaitCursor; if (cboAccName.SelectedIndex == -1) { return; } DBGrid.toolCancelFrozen_Click(null, null); modAccPeriodList modPeriod = (modAccPeriodList)cboAccName.SelectedItem; BindingCollection <modAccCredenceList> list = _dal.GetIList(modPeriod.AccName, string.Empty, Util.IsTrialBalance, out Util.emsg); DBGrid.DataSource = list; if (list == null && !string.IsNullOrEmpty(Util.emsg)) { MessageBox.Show(Util.emsg, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { AddComboBoxColumns(); for (int i = 0; i < list.Count; i++) { if (list[i].Status == 1) { DBGrid.Rows[i].DefaultCellStyle.ForeColor = Color.DarkGray; } } if (modPeriod.LockFlag == 1 || Util.IsTrialBalance) { toolNew.Visible = false; toolEdit.Visible = false; toolDel.Visible = false; toolAudit.Visible = false; toolReset.Visible = false; toolTrial.Visible = false; toolBalance.Visible = false; } else { toolNew.Visible = true; toolEdit.Visible = true; toolDel.Visible = true; toolAudit.Visible = true; toolReset.Visible = true; toolTrial.Visible = true; toolBalance.Visible = true; } } } catch (Exception ex) { MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } finally { this.Cursor = Cursors.Default; } }
/// <summary> /// get product wip info /// <summary> /// <param name=accname>accname</param> /// <param name=productid>productid</param> /// <param name=mod>model object of warehouseproductinout</param> /// <param name=out emsg>return error message</param> /// <returns>true/false</returns> public BindingCollection <modProductWip> GetProductWip(string accname, bool tempflag, out string emsg) { try { BindingCollection <modProductWip> modellist = new BindingCollection <modProductWip>(); //Execute a query to read the categories dalAccPeriodList dal = new dalAccPeriodList(); modAccPeriodList mod = dal.GetItem(accname, out emsg); string sql = string.Format("select count(1) from warehouse_product_inout where inout_date='{0}'", mod.StartDate); int cnt = Convert.ToInt32(SqlHelper.ExecuteScalar(sql)); if (cnt == 0 && mod.Seq > 1) { BalanceWip(mod.Seq - 1, mod.StartDate, out emsg); } if (mod.LockFlag == 0 && mod.EndDate < DateTime.Today) { mod.EndDate = DateTime.Today; } string tempwhere = string.Empty; if (tempflag) { tempwhere = "and b.product_type='临时' "; } string inoutdatewhere = "and a.inout_date >= '" + mod.StartDate + "' and a.inout_date <= '" + mod.EndDate + "' "; sql = "select a.product_id,b.product_name,b.min_qty,b.max_qty,sum(a.size * a.start_qty) start_qty,sum(a.size * a.input_qty) input_qty,sum(a.size * a.output_qty) output_qty " + "from warehouse_product_inout a inner join product_list b on a.product_id=b.product_id where 1=1 " + inoutdatewhere + tempwhere + "group by a.product_id,b.product_name,b.min_qty,b.max_qty order by a.product_id"; using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql)) { while (rdr.Read()) { modProductWip model = new modProductWip(); model.ProductId = dalUtility.ConvertToString(rdr["product_id"]); model.ProductName = dalUtility.ConvertToString(rdr["product_Name"]); model.StartQty = dalUtility.ConvertToDecimal(rdr["start_qty"]); model.InputQty = dalUtility.ConvertToDecimal(rdr["input_qty"]); model.OutputQty = dalUtility.ConvertToDecimal(rdr["output_qty"]); model.EndQty = model.StartQty + model.InputQty - model.OutputQty; model.MinQty = dalUtility.ConvertToDecimal(rdr["min_qty"]); model.MaxQty = dalUtility.ConvertToDecimal(rdr["max_qty"]); modellist.Add(model); } } emsg = null; return(modellist); } catch (Exception ex) { emsg = dalUtility.ErrorMessage(ex.Message); return(null); } }
/// <summary> /// get useless product /// <summary> /// <param name=out emsg>return error message</param> ///<returns>details of all productlist</returns> public BindingCollection <modProductList> GetUselessProduct(string accname, out string emsg) { try { BindingCollection <modProductList> modellist = new BindingCollection <modProductList>(); //Execute a query to read the categories int inoutdays = 30; dalSysParameters dalpara = new dalSysParameters(); modSysParameters modpara = dalpara.GetItem("PRODUCT_CLEAR_DAYS", out emsg); if (!string.IsNullOrEmpty(modpara.ParaValue) && Convert.ToInt32(modpara.ParaValue) >= inoutdays) { inoutdays = Convert.ToInt32(modpara.ParaValue); } dalAccPeriodList dalp = new dalAccPeriodList(); modAccPeriodList modp = dalp.GetItem(accname, out emsg); string sql = string.Format(@"select product_id,product_name,product_type,barcode,size_flag,specify,brand,unit_no,remark,min_qty,max_qty,update_user,update_time from product_list a where status<>7 and update_time<=getdate()-7 and not exists(select '#' from acc_product_inout where acc_name='{0}' and product_id=a.product_id) and not exists(select '#' from warehouse_product_inout where product_id=a.product_id and (inout_date>=getdate()-{1} or inout_date>='{2}')) order by update_time" , accname, inoutdays, modp.StartDate); using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql)) { while (rdr.Read()) { modProductList model = new modProductList(); model.ProductId = dalUtility.ConvertToString(rdr["product_id"]); model.ProductName = dalUtility.ConvertToString(rdr["product_name"]); model.ProductType = dalUtility.ConvertToString(rdr["product_type"]); model.Barcode = dalUtility.ConvertToString(rdr["barcode"]); model.SizeFlag = dalUtility.ConvertToInt(rdr["size_flag"]); model.Specify = dalUtility.ConvertToString(rdr["specify"]); model.Brand = dalUtility.ConvertToString(rdr["brand"]); model.UnitNo = dalUtility.ConvertToString(rdr["unit_no"]); model.Remark = dalUtility.ConvertToString(rdr["remark"]); model.MinQty = dalUtility.ConvertToDecimal(rdr["min_qty"]); model.MaxQty = dalUtility.ConvertToDecimal(rdr["max_qty"]); model.UpdateUser = dalUtility.ConvertToString(rdr["update_user"]); model.UpdateTime = dalUtility.ConvertToDateTime(rdr["update_time"]); modellist.Add(model); } } emsg = null; return(modellist); } catch (Exception ex) { emsg = dalUtility.ErrorMessage(ex.Message); return(null); } }
public void EditItem(modAccPeriodList mod) { _action = "EDIT"; txtAccName.Text = mod.AccName; txtAccYear.Text = mod.AccYear.ToString(); txtAccMonth.Text = mod.AccMonth.ToString(); txtEmployeeCount.Text = mod.EmployeeCount.ToString(); txtAccName.ReadOnly = true; txtAccYear.ReadOnly = true; txtAccMonth.ReadOnly = true; _userid = Util.UserId; }
public bool BalanceWip(int accpreviousseq, DateTime startdate, out string emsg) { dalAccPeriodList dal = new dalAccPeriodList(); modAccPeriodList modprevious = dal.GetItem(accpreviousseq, out emsg); string inoutdatewhere = "and a.inout_date >= '" + modprevious.StartDate + "' and a.inout_date <= '" + modprevious.EndDate + "' "; string sql = "insert into warehouse_product_inout(warehouse_id,product_id,size,form_id,form_type,inv_no,start_date,start_qty,input_qty,output_qty,remark,update_user,update_time) " + "select a.warehouse_id,a.product_id,a.size,0 form_id,'上月结存','','" + startdate + "',sum(a.start_qty) start_qty,sum(a.input_qty) input_qty,sum(a.output_qty) output_qty,'查询结转','Auto',getdate() " + "from warehouse_product_inout a where 1=1 " + inoutdatewhere + "group by a.warehouse_id,a.product_id,a.size"; SqlHelper.ExecuteNonQuery(sql); emsg = string.Empty; return(true); }
private void toolExport_Click(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; if (DBGrid1.CurrentRow == null) { return; } IList <modExcelRangeData> list = new List <modExcelRangeData>(); dalAccPeriodList dalp = new dalAccPeriodList(); modAccPeriodList modp = dalp.GetItem(cboAccName.ComboBox.SelectedValue.ToString(), out Util.emsg); list.Add(new modExcelRangeData(modp.EndDate.ToString("yyyy年MM月dd日"), "D3", "F3")); for (int i = 0; i < DBGrid1.RowCount; i++) { modAccAssetDebtReport modd = (modAccAssetDebtReport)DBGrid1.Rows[i].DataBoundItem; list.Add(new modExcelRangeData(modd.SubjectName, "A" + (6 + i).ToString().Trim(), "A" + (6 + i).ToString().Trim())); list.Add(new modExcelRangeData((i + 1).ToString(), "B" + (6 + i).ToString().Trim(), "B" + (6 + i).ToString().Trim())); list.Add(new modExcelRangeData(string.Format("{0:C2}", modd.YearStartMny), "C" + (6 + i).ToString().Trim(), "C" + (6 + i).ToString().Trim())); list.Add(new modExcelRangeData(string.Format("{0:C2}", modd.EndMny), "D" + (6 + i).ToString().Trim(), "D" + (6 + i).ToString().Trim())); } int rowindex = -1; for (int i = 0; i < DBGrid2.RowCount; i++) { modAccAssetDebtReport modd = (modAccAssetDebtReport)DBGrid2.Rows[i].DataBoundItem; if (modd.SubjectId.IndexOf("9135") < 0 || modd.SubjectId.Length != 8) { rowindex++; list.Add(new modExcelRangeData(modd.SubjectName, "F" + (6 + rowindex).ToString().Trim(), "F" + (6 + rowindex).ToString().Trim())); list.Add(new modExcelRangeData((rowindex + 1).ToString(), "G" + (6 + rowindex).ToString().Trim(), "G" + (6 + rowindex).ToString().Trim())); list.Add(new modExcelRangeData(string.Format("{0:C2}", modd.YearStartMny), "H" + (6 + rowindex).ToString().Trim(), "H" + (6 + rowindex).ToString().Trim())); list.Add(new modExcelRangeData(string.Format("{0:C2}", modd.EndMny), "I" + (6 + rowindex).ToString().Trim(), "I" + (6 + rowindex).ToString().Trim())); } } clsExport.ExportByTemplate(list, "资产负债表", 1, Util.Max(DBGrid1.RowCount, rowindex) + 2, 9, 1); } catch (Exception ex) { MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } finally { this.Cursor = Cursors.Default; } }
/// <summary> /// get table record /// <summary> /// <param name=accname>accname</param> /// <param name=out emsg>return error message</param> ///<returns>get a record detail of accperiodlist</returns> public modAccPeriodList GetDuringItem(DateTime duringDate, out string emsg) { try { //Execute a query to read the categories string sql = "select acc_name,seq,acc_year,acc_month,start_date,end_date,cost_flag,lock_flag,employee_count,update_user,update_time " + "from acc_period_list where start_date<=@duringDate and end_date>=@duringDate order by acc_name"; SqlParameter[] parm = { new SqlParameter("duringDate", SqlDbType.DateTime) }; parm[0].Value = duringDate; using (SqlDataReader rdr = SqlHelper.ExecuteReader(CommandType.Text, sql, parm)) { if (rdr.Read()) { modAccPeriodList model = new modAccPeriodList(); model.AccName = dalUtility.ConvertToString(rdr["acc_name"]); model.Seq = dalUtility.ConvertToInt(rdr["seq"]); model.AccYear = dalUtility.ConvertToInt(rdr["acc_year"]); model.AccMonth = dalUtility.ConvertToInt(rdr["acc_month"]); model.StartDate = dalUtility.ConvertToDateTime(rdr["start_date"]); model.EndDate = dalUtility.ConvertToDateTime(rdr["end_date"]); model.CostFlag = dalUtility.ConvertToInt(rdr["cost_flag"]); model.LockFlag = dalUtility.ConvertToInt(rdr["lock_flag"]); model.EmployeeCount = dalUtility.ConvertToInt(rdr["employee_count"]); model.UpdateUser = dalUtility.ConvertToString(rdr["update_user"]); model.UpdateTime = dalUtility.ConvertToDateTime(rdr["update_time"]); emsg = null; return(model); } else { emsg = "未找到财务区间数据!"; return(null); } } } catch (Exception ex) { emsg = dalUtility.ErrorMessage(ex.Message); return(null); } }
/// <summary> /// get product wip info /// <summary> /// <param name=accname>accname</param> /// <param name=productid>productid</param> /// <param name=mod>model object of warehouseproductinout</param> /// <param name=out emsg>return error message</param> /// <returns>true/false</returns> public modProductWip GetProductWipItem(string accname, string productid, out string emsg) { try { dalAccPeriodList dal = new dalAccPeriodList(); modAccPeriodList mod = dal.GetItem(accname, out emsg); string inoutdatewhere = "and a.inout_date >= '" + mod.StartDate + "' and a.inout_date <= '" + mod.EndDate + "' "; string sql = string.Format("select a.product_id,b.product_name,b.min_qty,b.max_qty,sum(a.size * a.start_qty) start_qty,sum(a.size * a.input_qty) input_qty,sum(a.size * a.output_qty) output_qty " + "from warehouse_product_inout a inner join product_list b on a.product_id=b.product_id where a.product_id='{0}' " + inoutdatewhere + "group by a.product_id,b.product_name,b.min_qty,b.max_qty", productid); using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql)) { if (rdr.Read()) { modProductWip model = new modProductWip(); model.ProductId = dalUtility.ConvertToString(rdr["product_id"]); model.ProductName = dalUtility.ConvertToString(rdr["product_Name"]); model.StartQty = dalUtility.ConvertToDecimal(rdr["start_qty"]); model.InputQty = dalUtility.ConvertToDecimal(rdr["input_qty"]); model.OutputQty = dalUtility.ConvertToDecimal(rdr["output_qty"]); model.EndQty = model.StartQty + model.InputQty - model.OutputQty; model.MinQty = dalUtility.ConvertToDecimal(rdr["min_qty"]); model.MaxQty = dalUtility.ConvertToDecimal(rdr["max_qty"]); emsg = string.Empty; return(model); } else { emsg = "No data found!"; return(null); } } } catch (Exception ex) { emsg = dalUtility.ErrorMessage(ex.Message); return(null); } }
/// <summary> /// get table record /// <summary> /// <param name=seq>seq</param> /// <param name=out emsg>return error message</param> ///<returns>get a record detail of accperiodlist</returns> public modAccPeriodList GetFirstItem(out string emsg) { try { //Execute a query to read the categories string sql = "select acc_name,seq,acc_year,acc_month,start_date,end_date,cost_flag,lock_flag,employee_count,update_user,update_time from acc_period_list " + "where seq=(select min(seq) from acc_period_list)"; using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql)) { if (rdr.Read()) { modAccPeriodList model = new modAccPeriodList(); model.AccName = dalUtility.ConvertToString(rdr["acc_name"]); model.Seq = dalUtility.ConvertToInt(rdr["seq"]); model.AccYear = dalUtility.ConvertToInt(rdr["acc_year"]); model.AccMonth = dalUtility.ConvertToInt(rdr["acc_month"]); model.StartDate = dalUtility.ConvertToDateTime(rdr["start_date"]); model.EndDate = dalUtility.ConvertToDateTime(rdr["end_date"]); model.CostFlag = dalUtility.ConvertToInt(rdr["cost_flag"]); model.LockFlag = dalUtility.ConvertToInt(rdr["lock_flag"]); model.EmployeeCount = dalUtility.ConvertToInt(rdr["employee_count"]); model.UpdateUser = dalUtility.ConvertToString(rdr["update_user"]); model.UpdateTime = dalUtility.ConvertToDateTime(rdr["update_time"]); emsg = null; return(model); } else { emsg = "Error on read data"; return(null); } } } catch (Exception ex) { emsg = dalUtility.ErrorMessage(ex.Message); return(null); } }
/// <summary> /// update a accperiodlist /// <summary> /// <param name=accname>accname</param> /// <param name=mod>model object of accperiodlist</param> /// <param name=out emsg>return error message</param> /// <returns>true/false</returns> public bool Update(string accname, modAccPeriodList mod, out string emsg) { try { string sql = string.Format("update acc_period_list set employee_count={0},update_user='******',update_time=getdate() where acc_name='{2}'", mod.EmployeeCount, mod.UpdateUser, accname); int i = SqlHelper.ExecuteNonQuery(sql); if (i > 0) { emsg = null; return(true); } else { emsg = "Unknown error when ExecuteNonQuery!"; return(false); } } catch (Exception ex) { emsg = dalUtility.ErrorMessage(ex.Message); return(false); } }
public void LoadData() { //try //{ // this.Cursor = Cursors.WaitCursor; dalAccPeriodList dalperiod = new dalAccPeriodList(); modAccPeriodList modYearStartPeriod = dalperiod.GetYearStartItem(cboAccName.ComboBox.SelectedValue.ToString(), out Util.emsg); //if(modYearStartPeriod == null) // modYearStartPeriod = dalperiod.GetFirstItem(out Util.emsg); dalAccSubjectList dalsubject = new dalAccSubjectList(); dalAccReport.staticSubjectList = dalsubject.GetAllList(true, out Util.emsg); dalAccReport.staticYearSubjectBalance = _dal.GetSubjectBalance(modYearStartPeriod.AccName, true, Util.IsTrialBalance, out Util.emsg); //上月结存 dalAccReport.staticEndSubjectBalance = _dal.GetSubjectBalance(cboAccName.ComboBox.SelectedValue.ToString(), false, Util.IsTrialBalance, out Util.emsg); List <modAccAssetDebtReport> list1 = new List <modAccAssetDebtReport>(); _dal.GetAccAssetDebtReport(cboAccName.ComboBox.SelectedValue.ToString(), "1", Util.IsTrialBalance, ref list1, out Util.emsg); DBGrid1.DataSource = list1; if (list1 == null && !string.IsNullOrEmpty(Util.emsg)) { MessageBox.Show(Util.emsg, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } else { DBGrid1.AlternatingRowsDefaultCellStyle.BackColor = Color.Empty; DBGrid1.Columns[0].Visible = false; DBGrid1.Columns[1].Visible = false; DBGrid1.Columns[3].Visible = false; DBGrid1.Columns[6].Visible = false; DBGrid1.Columns[7].Visible = false; DBGrid1.Columns[4].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; DBGrid1.Columns[5].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; DBGrid1.Columns[4].Width = 168; DBGrid1.Columns[5].Width = 168; Status1.Text = "资产总计: " + list1[0].EndMny.ToString(); } List <modAccAssetDebtReport> list2 = new List <modAccAssetDebtReport>(); _dal.GetAccAssetDebtReport(cboAccName.ComboBox.SelectedValue.ToString(), "5", Util.IsTrialBalance, ref list2, out Util.emsg); DBGrid2.DataSource = list2; if (list2 == null && !string.IsNullOrEmpty(Util.emsg)) { MessageBox.Show(Util.emsg, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } else { DBGrid2.AlternatingRowsDefaultCellStyle.BackColor = Color.Empty; DBGrid2.Columns[0].Visible = false; DBGrid2.Columns[1].Visible = false; DBGrid2.Columns[3].Visible = false; DBGrid2.Columns[6].Visible = false; DBGrid2.Columns[7].Visible = false; DBGrid2.Columns[4].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; DBGrid2.Columns[5].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; DBGrid2.Columns[4].Width = 168; DBGrid2.Columns[5].Width = 168; Status2.Text = "负债及权益总计: " + list2[0].EndMny.ToString(); } SetGridColor(); //} //catch (Exception ex) //{ // MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); // return; //} //finally //{ // this.Cursor = Cursors.Default; //} }
private void toolExport_Click(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; if (DBGrid.CurrentRow == null) { return; } IList <modExcelRangeData> list = new List <modExcelRangeData>(); list.Add(new modExcelRangeData(string.Format("{0}", clsLxms.GetParameterValue("COMPANY_NAME")), "C3", "D3")); modAccPeriodList modperiod = (modAccPeriodList)cboAccName.SelectedItem; list.Add(new modExcelRangeData(string.Format("{0}", modperiod.EndDate.ToString("yyyy年MM月dd日")), "F3", "F3")); int n = 0; bool nTT = false; for (int i = 0; i < DBGrid.RowCount; i++) { modAccExpenseReport modd = (modAccExpenseReport)DBGrid.Rows[i].DataBoundItem; if (modd.SubjectId == "913530") { list.Add(new modExcelRangeData(string.Format("{0:N2}", modd.ThisMonth), "C33", "C33")); list.Add(new modExcelRangeData(string.Format("{0:N2}", modd.ThisYear), "D33", "D33")); n = 0; } else if (modd.SubjectId == "913535") { list.Add(new modExcelRangeData(string.Format("{0:N2}", modd.ThisMonth), "G33", "G33")); list.Add(new modExcelRangeData(string.Format("{0:N2}", modd.ThisYear), "H33", "H33")); n = 0; } else if (modd.SubjectId == "913540") { list.Add(new modExcelRangeData(string.Format("{0:N2}", modd.ThisMonth), "C49", "C49")); list.Add(new modExcelRangeData(string.Format("{0:N2}", modd.ThisYear), "D49", "D49")); n = 0; } else if (modd.SubjectId.StartsWith("913530") && modd.SubjectId.Length == 8) { list.Add(new modExcelRangeData(string.Format("{0}", modd.SubjectName), "B" + (i + 6).ToString(), "B" + (i + 6).ToString())); list.Add(new modExcelRangeData(string.Format("{0:N2}", modd.ThisMonth), "C" + (i + 6).ToString(), "C" + (i + 6).ToString())); list.Add(new modExcelRangeData(string.Format("{0:N2}", modd.ThisYear), "D" + (i + 6).ToString(), "D" + (i + 6).ToString())); } else if (modd.SubjectId.StartsWith("913535") && modd.SubjectId.Length == 8) { list.Add(new modExcelRangeData(string.Format("{0}", modd.SubjectName), "F" + (n + 5).ToString(), "F" + (n + 5).ToString())); list.Add(new modExcelRangeData(string.Format("{0:N2}", modd.ThisMonth), "G" + (n + 5).ToString(), "G" + (n + 5).ToString())); list.Add(new modExcelRangeData(string.Format("{0:N2}", modd.ThisYear), "H" + (n + 5).ToString(), "H" + (n + 5).ToString())); } else if (modd.SubjectId.StartsWith("913540") && modd.SubjectId.Length == 8) { list.Add(new modExcelRangeData(string.Format("{0}", modd.SubjectName), "B" + (n + 36).ToString(), "B" + (n + 36).ToString())); list.Add(new modExcelRangeData(string.Format("{0:N2}", modd.ThisMonth), "C" + (n + 36).ToString(), "C" + (n + 36).ToString())); list.Add(new modExcelRangeData(string.Format("{0:N2}", modd.ThisYear), "D" + (n + 36).ToString(), "D" + (n + 36).ToString())); } else if (modd.SubjectId == "-") { if (!nTT) { n = 1; nTT = true; } list.Add(new modExcelRangeData(string.Format("{0}", modd.SubjectName), "F" + (n + 36).ToString(), "F" + (n + 36).ToString())); list.Add(new modExcelRangeData(string.Format("{0:N2}", modd.ThisMonth), "G" + (n + 36).ToString(), "G" + (n + 36).ToString())); list.Add(new modExcelRangeData(string.Format("{0:N2}", modd.ThisYear), "H" + (n + 36).ToString(), "H" + (n + 36).ToString())); } n++; } clsExport.ExportByTemplate(list, "费用统计表", 1, 49, 8, 1); } catch (Exception ex) { MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } finally { this.Cursor = Cursors.Default; } }
public bool RegenDailyReport(DateTime reportDate, out string emsg) { using (TransactionScope transaction = new TransactionScope()) //使用事务 { try { var dalPeriod = new dalAccPeriodList(); modAccPeriodList modPeriod = dalPeriod.GetDuringItem(reportDate, out emsg); if (modPeriod == null) { return(false); } string sql = "delete from warehouse_inout_daily_report where report_date=@report_date"; SqlParameter[] parm = { new SqlParameter("report_date", SqlDbType.DateTime) }; parm[0].Value = reportDate; int i = SqlHelper.ExecuteNonQuery(CommandType.Text, sql, parm); sql = "select a.product_id,a.size*(a.start_qty+a.input_qty-a.output_qty) as start_qty,0 end_qty,0 purchase_qty,0 sale_qty,0 as overflow_qty,0 loss_qty,0 production_output,0 production_input,0 transfer_output,0 transfer_input " + "from warehouse_product_inout a where a.inout_date between @first_date and @yesterday_date " + "union all select a.product_id,0 start_qty,a.size * (a.start_qty + a.input_qty - a.output_qty) as end_qty,0 purchase_qty,0 sale_qty,0 as overflow_qty,0 loss_qty,0 production_output,0 production_input,0 transfer_output,0 transfer_input " + "from warehouse_product_inout a where a.inout_date between @first_date and @today_date " + "union all select a.product_id,0 start_qty,0 end_qty,a.size*(a.input_qty-a.output_qty) purchase_qty,0 sale_qty,0 as overflow_qty,0 loss_qty,0 production_output,0 production_input,0 transfer_output,0 transfer_input " + "from warehouse_product_inout a where a.form_type in ('采购收货','采购退货') and a.inout_date = @inout_date " + "union all select a.product_id,0 start_qty,0 end_qty,0 purchase_qty,a.size*(a.output_qty-a.input_qty) sale_qty,0 as overflow_qty,0 loss_qty,0 production_output,0 production_input,0 transfer_output,0 transfer_input " + "from warehouse_product_inout a where a.form_type in ('送货单','退货单') and a.inout_date = @inout_date " + "union all select a.product_id,0 start_qty,0 end_qty,0 purchase_qty,0 sale_qty,a.size*a.input_qty as overflow_qty,a.size*a.output_qty as loss_qty,0 production_output,0 production_input,0 transfer_output,0 transfer_input " + "from warehouse_product_inout a where a.form_type in ('溢余入库','借入物入库','借出物入库','损耗出库','借入物出库','借出物出库') and a.inout_date = @inout_date " + "union all select a.product_id,0 start_qty,0 end_qty,0 purchase_qty,0 sale_qty,0 overflow_qty,0 loss_qty,a.size*a.input_qty production_output,a.size*a.output_qty production_input,0 transfer_output,0 transfer_input " + "from warehouse_product_inout a where a.form_type in ('外发单','内部单') and a.inout_date = @inout_date " + "union all select a.product_id,0 start_qty,0 end_qty,0 purchase_qty,0 sale_qty,0 overflow_qty,0 loss_qty,0 production_output,0 production_input,a.size*a.output_qty transfer_output,a.size*a.input_qty transfer_input " + "from warehouse_product_inout a where a.form_type in ('转仓入库','转仓出库') and a.inout_date = @inout_date"; sql = "insert into warehouse_inout_daily_report(report_date,product_id,start_qty,end_qty,purchase_qty,sale_qty,overflow_qty,loss_qty,production_output,production_input,transfer_output,transfer_input) " + "select @reportDate,product_id,sum(start_qty) start_qty,sum(end_qty) end_qty,sum(purchase_qty) purchase_qty,sum(sale_qty) sale_qty,sum(overflow_qty) overflow_qty,sum(loss_qty) loss_qty," + "sum(production_output) production_output,sum(production_input) production_input,sum(transfer_output) transfer_output,sum(transfer_input) transfer_input " + "from ( " + sql + ") t group by product_id"; SqlParameter[] parm2 = { new SqlParameter("reportDate", SqlDbType.DateTime), new SqlParameter("first_date", SqlDbType.DateTime), new SqlParameter("yesterday_date", SqlDbType.DateTime), new SqlParameter("today_date", SqlDbType.DateTime), new SqlParameter("inout_date", SqlDbType.DateTime) }; parm2[0].Value = reportDate; parm2[1].Value = modPeriod.StartDate; parm2[2].Value = reportDate.AddDays(-1); parm2[3].Value = reportDate; parm2[4].Value = reportDate; i = SqlHelper.ExecuteNonQuery(CommandType.Text, sql, parm2); transaction.Complete(); //就这句就可以了。 if (i > 0) { emsg = string.Empty; } else { emsg = "未产生任何数据!"; } return(true); } catch (Exception ex) { emsg = ex.Message; return(false); } } }
/// <summary> /// save init receivable data /// <summary> /// <param name=accname>accname</param> /// <param name=startdate>startdate</param> /// <param name=currency>currency</param> /// <param name=exchangerate>exchangerate</param> /// <param name=list>list of modStartReceivable</param> /// <param name=out emsg>return error message</param> /// <returns>true/false</returns> public bool Insert(modAccPeriodList mod, out string emsg) { using (TransactionScope transaction = new TransactionScope())//使用事务 { try { string sql = "select count(1) from acc_period_list where lock_flag=0"; int count = Convert.ToInt32(SqlHelper.ExecuteScalar(sql)); if (count >= 1) { emsg = "前一个财务区间还未结算,不能创建新的财务区间!"; return(false); } sql = "select isnull(max(seq),0) +1 from acc_period_list"; int seq = Convert.ToInt32(SqlHelper.ExecuteScalar(sql)); if (seq > 1) { sql = "select count(1) from acc_period_list where end_date='" + mod.StartDate.AddDays(-1) + "'"; count = Convert.ToInt32(SqlHelper.ExecuteScalar(sql)); if (count <= 0) { emsg = "前一个财务区间与当前财务区间的日期不连续!"; return(false); } } sql = string.Format("insert into acc_period_list(acc_name,seq,acc_year,acc_month,start_date,end_date,cost_flag,lock_flag,employee_count,update_user,update_time)values('{0}',{1},{2},{3},'{4}','{5}',{6},{7},{8},'{9}',getdate())", mod.AccName, seq, mod.AccYear, mod.AccMonth, mod.StartDate, mod.EndDate, mod.CostFlag, mod.LockFlag, mod.EmployeeCount, mod.UpdateUser); SqlHelper.ExecuteNonQuery(sql); if (seq == 1) { sql = string.Format("delete acc_credence_list where acc_name='{0}' and seq=0", mod.AccName); SqlHelper.ExecuteNonQuery(sql); sql = string.Format("insert into acc_credence_list(acc_name,seq,status,credence_type,credence_word,credence_date,attach_count,remark,update_user,update_time)values('{0}',{1},{2},'{3}','{4}','{5}',{6},'{7}','{8}',getdate())", mod.AccName, 0, 1, "期初数据", "初", mod.StartDate, 1, "期初设定", mod.UpdateUser); SqlHelper.ExecuteNonQuery(sql); } else { sql = string.Format("delete acc_credence_detail where acc_name='{0}' and seq=0", mod.AccName); SqlHelper.ExecuteNonQuery(sql); sql = string.Format("delete acc_credence_list where acc_name='{0}' and seq=0", mod.AccName); SqlHelper.ExecuteNonQuery(sql); modAccPeriodList modpre = GetItem(seq - 1, out emsg); sql = string.Format("insert into acc_credence_list(acc_name,seq,status,credence_type,credence_word,credence_date,attach_count,remark,update_user,update_time)values('{0}',{1},{2},'{3}','{4}','{5}',{6},'{7}','{8}',getdate())", mod.AccName, 0, 1, "上月结存", "初", mod.StartDate, 1, "上月结存", mod.UpdateUser); SqlHelper.ExecuteNonQuery(sql); sql = string.Format("delete acc_receivable_list where acc_name='{0}' and seq=0", mod.AccName); SqlHelper.ExecuteNonQuery(sql); sql = string.Format("insert into acc_receivable_list(acc_name,seq,acc_date,cust_id,currency,exchange_rate,start_mny,adding_mny,paid_mny,form_id,form_type,remark,update_user,update_time) " + "select '{0}',0,'{1}',cust_id,currency,exchange_rate,sum(start_mny+adding_mny-paid_mny) start_mny,0,0,'0','上月结存','','{2}',getdate() from acc_receivable_list where acc_name='{3}' group by cust_id,currency,exchange_rate", mod.AccName, mod.StartDate, mod.UpdateUser, modpre.AccName); SqlHelper.ExecuteNonQuery(sql); sql = string.Format("delete acc_payable_list where acc_name='{0}' and seq=0", mod.AccName); SqlHelper.ExecuteNonQuery(sql); sql = string.Format("insert into acc_payable_list(acc_name,seq,acc_date,vendor_name,currency,exchange_rate,start_mny,adding_mny,paid_mny,form_id,form_type,remark,update_user,update_time) " + "select '{0}',0,'{1}',vendor_name,currency,exchange_rate,sum(start_mny+adding_mny-paid_mny) start_mny,0,0,'0','上月结存','','{2}',getdate() from acc_payable_list where acc_name='{3}' group by vendor_name,currency,exchange_rate", mod.AccName, mod.StartDate, mod.UpdateUser, modpre.AccName); SqlHelper.ExecuteNonQuery(sql); sql = string.Format("delete acc_other_receivable where acc_name='{0}' and seq=0", mod.AccName); SqlHelper.ExecuteNonQuery(sql); sql = string.Format("insert into acc_other_receivable(acc_name,seq,acc_date,object_name,currency,exchange_rate,start_mny,adding_mny,paid_mny,form_id,form_type,remark,update_user,update_time) " + "select '{0}',0,'{1}',object_name,currency,exchange_rate,sum(start_mny+adding_mny-paid_mny) start_mny,0,0,'0','上月结存','','{2}',getdate() from acc_other_receivable where acc_name='{3}' group by object_name,currency,exchange_rate", mod.AccName, mod.StartDate, mod.UpdateUser, modpre.AccName); SqlHelper.ExecuteNonQuery(sql); sql = string.Format("delete acc_other_payable where acc_name='{0}' and seq=0", mod.AccName); SqlHelper.ExecuteNonQuery(sql); sql = string.Format("insert into acc_other_payable(acc_name,seq,acc_date,object_name,currency,exchange_rate,start_mny,adding_mny,paid_mny,form_id,form_type,remark,update_user,update_time) " + "select '{0}',0,'{1}',object_name,currency,exchange_rate,sum(start_mny+adding_mny-paid_mny) start_mny,0,0,'0','上月结存','','{2}',getdate() from acc_other_payable where acc_name='{3}' group by object_name,currency,exchange_rate", mod.AccName, mod.StartDate, mod.UpdateUser, modpre.AccName); SqlHelper.ExecuteNonQuery(sql); sql = string.Format("delete acc_product_inout where acc_name='{0}' and acc_seq=0", mod.AccName); SqlHelper.ExecuteNonQuery(sql); sql = string.Format("insert into acc_product_inout(acc_name,acc_seq,acc_date,product_id,size,start_qty,start_qty2,start_mny,start_mny2,input_qty,input_mny,output_qty,output_mny,form_id,form_type,remark,update_user,update_time) " + "select '{0}',0,'{1}',product_id,size,sum(start_qty+input_qty-output_qty) start_qty,sum(start_qty+input_qty-output_qty) start_qty2,sum(start_mny+input_mny-output_mny) start_mny,sum(start_mny+input_mny-output_mny) start_mny2,0,0,0,0,'0','上月结存','','{2}',getdate() from acc_product_inout " + "where acc_name='{3}' group by product_id,size having (sum(start_qty+input_qty-output_qty)<>0 or sum(start_mny+input_mny-output_mny)<>0) ", mod.AccName, mod.StartDate, mod.UpdateUser, modpre.AccName); SqlHelper.ExecuteNonQuery(sql); sql = string.Format("delete warehouse_product_inout where form_type='{0}' and inout_date='{1}'", "上月结存", mod.StartDate); SqlHelper.ExecuteNonQuery(sql); sql = "insert into warehouse_product_inout(warehouse_id,product_id,size,form_id,form_type,inv_no,inout_date,start_qty,input_qty,output_qty,remark,update_user,update_time) " + "select warehouse_id,product_id,size,0,'上月结存','','" + mod.StartDate + "',sum(start_qty+input_qty-output_qty),0,0,'','" + mod.UpdateUser + "',getdate() " + "from warehouse_product_inout where inout_date>='" + modpre.StartDate + "' and inout_date<='" + modpre.EndDate + "' group by warehouse_id,product_id,size"; SqlHelper.ExecuteNonQuery(sql); sql = string.Format("insert into acc_credence_detail(acc_name,seq,detail_seq,digest,subject_id,subject_name,detail_id,detail_name,borrow_money,lend_money,exchange_rate,zcfz_flag,ad_flag,currency) " + "select '{0}',0,row_number() over(order by subject_id) as detail_seq,'上月结存',subject_id,subject_name,detail_id,'' detail_name,sum(borrow_money),sum(lend_money),exchange_rate,zcfz_flag,ad_flag,currency " + "from acc_credence_detail where acc_name='{1}' and subject_id='1030' group by subject_id,subject_name,detail_id,exchange_rate,zcfz_flag,ad_flag,currency", mod.AccName, modpre.AccName); SqlHelper.ExecuteNonQuery(sql); sql = string.Format("insert into acc_credence_detail(acc_name,seq,detail_seq,digest,subject_id,subject_name,detail_id,detail_name,borrow_money,lend_money,exchange_rate,zcfz_flag,ad_flag,currency) " + "select '{0}',0,(row_number() over(order by subject_id)+800) as detail_seq,'上月结存',subject_id,subject_name,'' detail_id,'' detail_name,sum(borrow_money),sum(lend_money),exchange_rate,zcfz_flag,ad_flag,currency " + "from acc_credence_detail where acc_name='{1}' and subject_id<>'1030' group by subject_id,subject_name,exchange_rate,zcfz_flag,ad_flag,currency", mod.AccName, modpre.AccName); SqlHelper.ExecuteNonQuery(sql); } transaction.Complete();//就这句就可以了。 emsg = string.Empty; return(true); } catch (Exception ex) { emsg = dalUtility.ErrorMessage(ex.Message); return(false); } } }
public bool RebuildStartData(string accname, string subjectid, out string emsg) { try { string sql = string.Empty; modAccPeriodList mod = GetItem(accname, out emsg); modAccPeriodList modpre = GetItem(mod.Seq - 1, out emsg); switch (subjectid) { case "1030": //现金银行 sql = string.Format("delete acc_credence_detail where acc_name='{0}' and subject_id='1030' and seq=0", mod.AccName); SqlHelper.ExecuteNonQuery(sql); sql = string.Format("insert into acc_credence_detail(acc_name,seq,detail_seq,digest,subject_id,subject_name,detail_id,detail_name,borrow_money,lend_money,exchange_rate,zcfz_flag,ad_flag,currency) " + "select '{0}',0,row_number() over(order by subject_id) as detail_seq,'上月结存',subject_id,subject_name,detail_id,'' detail_name,sum(borrow_money),sum(lend_money),exchange_rate,zcfz_flag,ad_flag,currency " + "from acc_credence_detail where acc_name='{1}' and subject_id='1030' group by subject_id,subject_name,detail_id,exchange_rate,zcfz_flag,ad_flag,currency", mod.AccName, modpre.AccName); SqlHelper.ExecuteNonQuery(sql); break; case "1235": //库存商品 sql = string.Format("delete acc_product_inout where acc_name='{0}' and acc_seq=0", accname); SqlHelper.ExecuteNonQuery(sql); sql = string.Format("insert into acc_product_inout(acc_name,acc_seq,acc_date,product_id,size,start_qty,start_qty2,start_mny,start_mny2,input_qty,input_mny,output_qty,output_mny,form_id,form_type,remark,update_user,update_time) " + "select '{0}',0,'{1}',product_id,size,sum(start_qty+input_qty-output_qty) start_qty,sum(start_qty+input_qty-output_qty) start_qty2,sum(start_mny+input_mny-output_mny) start_mny,sum(start_mny+input_mny-output_mny) start_mny2,0,0,0,0,'0','上月结存','','{2}',getdate() from acc_product_inout " + "where acc_name='{3}' group by product_id,size having (sum(start_qty+input_qty-output_qty)<>0 or sum(start_mny+input_mny-output_mny)<>0) ", mod.AccName, mod.StartDate, mod.UpdateUser, modpre.AccName); SqlHelper.ExecuteNonQuery(sql); sql = string.Format("delete warehouse_product_inout where form_type='{0}' and inout_date='{1}'", "上月结存", mod.StartDate); SqlHelper.ExecuteNonQuery(sql); sql = "insert into warehouse_product_inout(warehouse_id,product_id,size,form_id,form_type,inv_no,inout_date,start_qty,input_qty,output_qty,remark,update_user,update_time) " + "select warehouse_id,product_id,size,0,'上月结存','','" + mod.StartDate + "',sum(start_qty+input_qty-output_qty),0,0,'','" + mod.UpdateUser + "',getdate() " + "from warehouse_product_inout where inout_date>='" + modpre.StartDate + "' and inout_date<='" + modpre.EndDate + "' group by warehouse_id,product_id,size"; SqlHelper.ExecuteNonQuery(sql); break; case "1055": //应收帐款 sql = string.Format("delete acc_receivable_list where acc_name='{0}' and seq=0", mod.AccName); SqlHelper.ExecuteNonQuery(sql); sql = string.Format("insert into acc_receivable_list(acc_name,seq,acc_date,cust_id,currency,exchange_rate,start_mny,adding_mny,paid_mny,form_id,form_type,remark,update_user,update_time) " + "select '{0}',0,'{1}',cust_id,currency,exchange_rate,sum(start_mny+adding_mny-paid_mny) start_mny,0,0,'0','上月结存','','{2}',getdate() from acc_receivable_list where acc_name='{3}' group by cust_id,currency,exchange_rate", mod.AccName, mod.StartDate, mod.UpdateUser, modpre.AccName); SqlHelper.ExecuteNonQuery(sql); break; case "5145": //应付账款 sql = string.Format("delete acc_payable_list where acc_name='{0}' and seq=0", mod.AccName); SqlHelper.ExecuteNonQuery(sql); sql = string.Format("insert into acc_payable_list(acc_name,seq,acc_date,vendor_name,currency,exchange_rate,start_mny,adding_mny,paid_mny,form_id,form_type,remark,update_user,update_time) " + "select '{0}',0,'{1}',vendor_name,currency,exchange_rate,sum(start_mny+adding_mny-paid_mny) start_mny,0,0,'0','上月结存','','{2}',getdate() from acc_payable_list where acc_name='{3}' group by vendor_name,currency,exchange_rate", mod.AccName, mod.StartDate, mod.UpdateUser, modpre.AccName); SqlHelper.ExecuteNonQuery(sql); break; case "1060": //其它应收款 sql = string.Format("delete acc_other_receivable where acc_name='{0}' and seq=0", mod.AccName); SqlHelper.ExecuteNonQuery(sql); sql = string.Format("insert into acc_other_receivable(acc_name,seq,acc_date,object_name,currency,exchange_rate,start_mny,adding_mny,paid_mny,form_id,form_type,remark,update_user,update_time) " + "select '{0}',0,'{1}',object_name,currency,exchange_rate,sum(start_mny+adding_mny-paid_mny) start_mny,0,0,'0','上月结存','','{2}',getdate() from acc_other_receivable where acc_name='{3}' group by object_name,currency,exchange_rate", mod.AccName, mod.StartDate, mod.UpdateUser, modpre.AccName); SqlHelper.ExecuteNonQuery(sql); break; case "5155": //其他应付款 sql = string.Format("delete acc_other_payable where acc_name='{0}' and seq=0", mod.AccName); SqlHelper.ExecuteNonQuery(sql); sql = string.Format("insert into acc_other_payable(acc_name,seq,acc_date,object_name,currency,exchange_rate,start_mny,adding_mny,paid_mny,form_id,form_type,remark,update_user,update_time) " + "select '{0}',0,'{1}',object_name,currency,exchange_rate,sum(start_mny+adding_mny-paid_mny) start_mny,0,0,'0','上月结存','','{2}',getdate() from acc_other_payable where acc_name='{3}' group by object_name,currency,exchange_rate", mod.AccName, mod.StartDate, mod.UpdateUser, modpre.AccName); SqlHelper.ExecuteNonQuery(sql); break; default: emsg = "无法重建该科目的期初数据"; return(false); } return(true); } catch (Exception ex) { emsg = dalUtility.ErrorMessage(ex.Message); return(false); } }
private void toolSave_Click(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; if (string.IsNullOrEmpty(txtAccName.Text.Trim())) { MessageBox.Show(clsTranslate.TranslateString("Subject Id") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtAccName.Focus(); return; } if (string.IsNullOrEmpty(txtAccYear.Text.Trim())) { MessageBox.Show(clsTranslate.TranslateString("Acc Year") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtAccYear.Focus(); return; } else if (!Util.IsNumeric(txtAccYear.Text)) { MessageBox.Show(clsTranslate.TranslateString("Acc Year") + clsTranslate.TranslateString(" must be numeric!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtAccYear.Focus(); return; } if (string.IsNullOrEmpty(txtAccMonth.Text.Trim())) { MessageBox.Show(clsTranslate.TranslateString("Acc Month") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtAccMonth.Focus(); return; } else if (!Util.IsNumeric(txtAccMonth.Text)) { MessageBox.Show(clsTranslate.TranslateString("Acc Month") + clsTranslate.TranslateString(" must be numeric!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtAccMonth.Focus(); return; } if (string.IsNullOrEmpty(txtEmployeeCount.Text.Trim())) { MessageBox.Show(clsTranslate.TranslateString("Employee Count") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtEmployeeCount.Focus(); return; } else if (!Util.IsNumeric(txtEmployeeCount.Text)) { MessageBox.Show(clsTranslate.TranslateString("Employee Count") + clsTranslate.TranslateString(" must be numeric!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtEmployeeCount.Focus(); return; } modAccPeriodList mod = new modAccPeriodList(); mod.AccYear = Convert.ToInt32(txtAccYear.Text); mod.AccMonth = Convert.ToInt32(txtAccMonth.Text); mod.AccName = txtAccName.Text.Trim(); mod.StartDate = Convert.ToDateTime(mod.AccYear.ToString().Trim() + "-" + mod.AccMonth.ToString().Trim() + "-" + "1"); mod.EndDate = mod.StartDate.AddMonths(1).AddDays(-1); mod.EmployeeCount = Convert.ToInt32(txtEmployeeCount.Text); mod.CostFlag = 0; mod.LockFlag = 0; mod.UpdateUser = _userid; bool ret = false; if (_action == "ADD") { ret = _dal.Insert(mod, out Util.emsg); } else { ret = _dal.Update(txtAccName.Text.Trim(), mod, out Util.emsg); } if (ret) { Util.retValue1 = txtAccName.Text.Trim(); this.DialogResult = DialogResult.OK; this.Dispose(); } else { MessageBox.Show(Util.emsg, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } catch (Exception ex) { MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } finally { this.Cursor = Cursors.Default; } }
private void DBGrid_DoubleClick(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; if (DBGrid.CurrentRow == null) { return; } string productid = DBGrid.CurrentRow.Cells["ProductId"].Value.ToString(); string warehouseid = string.Empty; string size = string.Empty; string fromdate = string.Empty; string todate = string.Empty; modAccPeriodList mod = (modAccPeriodList)cboAccName.SelectedItem; fromdate = mod.StartDate.ToString("MM-dd-yyyy"); if (mod.LockFlag == 0) { todate = mod.EndDate >= DateTime.Today ? mod.EndDate.ToString("MM-dd-yyyy") : DateTime.Today.ToString("MM-dd-yyyy"); } else { todate = mod.EndDate.ToString("MM-dd-yyyy"); } if (rbProductSizeWip.Checked) { size = DBGrid.CurrentRow.Cells["size"].Value.ToString(); } else if (rbWarehouseProductWip.Checked) { warehouseid = DBGrid.CurrentRow.Cells["warehouseid"].Value.ToString(); } else if (rbWarehouseProductSizeWip.Checked) { warehouseid = DBGrid.CurrentRow.Cells["warehouseid"].Value.ToString(); size = DBGrid.CurrentRow.Cells["size"].Value.ToString(); } BindingCollection <modWarehouseProductInout> list = _dal.GetIList(warehouseid, productid, string.Empty, size, string.Empty, fromdate, todate, out Util.emsg); if (list != null && list.Count > 0) { frmViewList frm = new frmViewList(); frm.InitViewList(this.Text, list); frm.ShowDialog(); } else { if (!string.IsNullOrEmpty(Util.emsg)) { MessageBox.Show(Util.emsg, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception ex) { MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } finally { this.Cursor = Cursors.Default; } }