private void DBGrid_DoubleClick(object sender, EventArgs e) { if (DBGrid.CurrentRow == null) { return; } string statuslist = "9"; if (chkNotAudit.Checked) { statuslist += ",0"; } if (chkAudited.Checked) { statuslist += ",1"; } BindingCollection <modProductionForm> list = new BindingCollection <modProductionForm>(); if (DBGrid.CurrentRow.Index == DBGrid.RowCount - 1) { list = _dal.GetIList(statuslist, string.Empty, string.Empty, string.Empty, txtInvNo.Text.Trim(), txtDeptId.Text.Trim(), dtpFrom.Text, dtpTo.Text, out Util.emsg); } else { modProductionSummary moditem = (modProductionSummary)DBGrid.CurrentRow.DataBoundItem; list = _dal.GetIList(statuslist, string.Empty, string.Empty, string.Empty, txtInvNo.Text.Trim(), moditem.DeptId, dtpFrom.Text, dtpTo.Text, out Util.emsg); } if (list != null && list.Count > 0) { frmViewList frm = new frmViewList(); frm.InitViewList(clsTranslate.TranslateString("Production Form"), list); frm.ShowDialog(); } }
/// <summary> /// get production summary /// <summary> /// <param name=statuslist>statuslist</param> /// <param name=formidlist>formidlist</param> /// <param name=formtypelist>formtypelist</param> /// <param name=deptlist>deptlist</param> /// <param name=fromdate>fromdate</param> /// <param name=todate>todate</param> /// <param name=out emsg>return error message</param> ///<returns>details of all productionform</returns> public BindingCollection <modProductionSummary> GetProductionSummary(string statuslist, string formidlist, string formtypelist, string deptlist, string nolist, string deptid, string fromdate, string todate, out string emsg) { try { BindingCollection <modProductionSummary> modellist = new BindingCollection <modProductionSummary>(); //Execute a query to read the categories string statuswhere = string.Empty; if (!string.IsNullOrEmpty(statuslist) && statuslist.CompareTo("ALL") != 0) { statuswhere = "and a.status in ('" + statuslist.Replace(",", "','") + "') "; } string formidwhere = string.Empty; if (!string.IsNullOrEmpty(formidlist) && formidlist.CompareTo("ALL") != 0) { formidwhere = "and a.form_id in ('" + formidlist.Replace(",", "','") + "') "; } string formtypewhere = string.Empty; if (!string.IsNullOrEmpty(formtypelist) && formtypelist.CompareTo("ALL") != 0) { formtypewhere = "and a.form_type in ('" + formtypelist.Replace(",", "','") + "') "; } string deptwhere = string.Empty; if (!string.IsNullOrEmpty(deptlist) && deptlist.CompareTo("ALL") != 0) { deptwhere = "and a.dept_id in ('" + deptlist.Replace(",", "','") + "') "; } string nolistwhere = string.Empty; if (!string.IsNullOrEmpty(nolist) && nolist.CompareTo("ALL") != 0) { nolistwhere = "and a.no in ('" + nolist.Replace(",", "','") + "') "; } string deptidwhere = string.Empty; if (!string.IsNullOrEmpty(deptid) && deptid.CompareTo("ALL") != 0) { deptidwhere = "and a.dept_id like '" + deptid + "%' "; } string formdatewhere = string.Empty; if (!string.IsNullOrEmpty(fromdate)) { formdatewhere = "and a.form_date >= '" + Convert.ToDateTime(fromdate) + "' "; } if (!string.IsNullOrEmpty(todate)) { formdatewhere += "and a.form_date <= '" + Convert.ToDateTime(todate) + "' "; } decimal processmny = 0; decimal sumdetail = 0; decimal sumkill = 0; decimal sumother = 0; string sql = "select form_type,dept_id,currency,sum(process_mny) process_mny,sum(detail_sum) detail_sum, sum(kill_mny) kill_mny, sum(other_mny) other_mny from production_form a where 1=1 " + statuswhere + formidwhere + formtypewhere + deptwhere + nolistwhere + deptidwhere + formdatewhere + "group by form_type,dept_id,currency order by form_type,dept_id"; using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql)) { while (rdr.Read()) { modProductionSummary model = new modProductionSummary(); model.FormType = dalUtility.ConvertToString(rdr["form_type"]); model.DeptId = dalUtility.ConvertToString(rdr["dept_id"]); model.ProcessMny = dalUtility.ConvertToDecimal(rdr["process_mny"]); model.DetailSum = dalUtility.ConvertToDecimal(rdr["detail_sum"]); model.KillMny = dalUtility.ConvertToDecimal(rdr["kill_mny"]); model.OtherMny = dalUtility.ConvertToDecimal(rdr["other_mny"]); model.Currency = dalUtility.ConvertToString(rdr["currency"]); processmny += model.ProcessMny; sumdetail += model.DetailSum; sumkill += model.KillMny; sumother += model.OtherMny; modellist.Add(model); } } modProductionSummary modsum = new modProductionSummary(); modsum.FormType = "合计"; modsum.DeptId = "合计"; modsum.ProcessMny = processmny; modsum.DetailSum = sumdetail; modsum.KillMny = sumkill; modsum.OtherMny = sumother; modellist.Add(modsum); emsg = null; return(modellist); } catch (Exception ex) { emsg = dalUtility.ErrorMessage(ex.Message); return(null); } }