123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381 |
- using LYFZ.Model;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Windows.Forms;
- namespace LYFZ.Software.MainBusiness.DecisionAssistant.SetSmallForm
- {
- public partial class AnalyzedOrderDetailSmallForm : UI.DecisionAssistant.SetSmallForm.AnalyzedOrderDetailSmallForm
- {
- LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
- public AnalyzedOrderDetailSmallForm()
- {
- InitializeComponent();
- this.Load += AnalyzedOrderDetailSmallForm_Load;
- }
- void AnalyzedOrderDetailSmallForm_Load(object sender, EventArgs e)
- {
- this.btn_Export.Click += btn_Export_Click;
- }
- void btn_Export_Click(object sender, EventArgs e)
- {
- this.gridViewDetail.ExportDataTable();
- }
- void SetDataTablePaymentNull( DataTable DataTableDb)
- {
- foreach(DataRow dr in DataTableDb.Rows)
- {
- if(DataTableDb.Columns.Contains("付款方式"))
- {
- if (string.IsNullOrEmpty(dr["付款方式"].ToString()))
- {
- dr["付款方式"] = "";
- }
-
- }
- }
- }
- public void BindDataGridView(ModelImagePostionAction modelImagePostionAction)
- {
- DataTable DataTableDb = orbll.GetView_Custom(modelImagePostionAction.SqlData).Tables[0];
- SetDataTablePaymentNull(DataTableDb);
- BindDataGridView(modelImagePostionAction, DataTableDb);
- }
- public void BindDataGridView2(ModelImagePostionAction modelImagePostionAction)
- {
- DataSet ds=orbll.GetView_Custom(modelImagePostionAction.SqlData);
- DataTable DataTableDb = ds.Tables[0];
- DataTable DataTableDb1 = ds.Tables[1];
- SetDataTablePaymentNull(DataTableDb);
- SetDataTablePaymentNull(DataTableDb1);
- for (int j = 0; j < DataTableDb.Rows.Count; j++)
- {
- DataRow dr = DataTableDb.Rows[j];
- if (dr["OrdersPerson"].ToString().Trim().Length != dr["OrdersPerson"].ToString().Trim().Replace(",", "").Length)
- {
- string[] StrArrayPerson = dr["OrdersPerson"].ToString().Trim().Split(',');
- if (StrArrayPerson[0].Trim() == modelImagePostionAction.ColumType)
- {
- dr["订单号"] = dr["订单号"] + "(主门市)";
- }
- else
- {
- dr["订单号"] = dr["订单号"] + "(副门市)";
- }
- }
- else
- {
- dr["订单号"] = dr["订单号"] + "(主门市)";
- }
- }
- for (int j = 0; j < DataTableDb1.Rows.Count; j++)
- {
- DataRow tempDataRow = DataTableDb1.Rows[j];
- DataRow dataRow = DataTableDb.NewRow();
- foreach (DataColumn header in DataTableDb1.Columns)
- {
- if (header.ColumnName == "订单号")
- {
- dataRow[header.ColumnName] = tempDataRow[header.ColumnName] + "(二销)";
-
- }
- else
- {
- dataRow[header.ColumnName] = tempDataRow[header.ColumnName];
- }
- }
- DataTableDb.Rows.Add(dataRow);
- }
- DataTableDb.Columns.Remove("OrdersPerson");
- BindDataGridView(modelImagePostionAction, DataTableDb);
- this.Width = 850;
- }
- public void BindDataGridView3(ModelImagePostionAction modelImagePostionAction)
- {
- DataSet ds = orbll.GetView_Custom(modelImagePostionAction.SqlData);
- DataTable DataTableDb = ds.Tables[0];
- SetDataTablePaymentNull(DataTableDb);
- List<string> strWhereList = new List<string>();
- string strWhere = "";
- foreach(DataRow dr in DataTableDb.Rows)
- {
- if(!strWhereList.Contains(Convert.ToString(dr["摄影师"].ToString())))
- {
- strWhereList.Add(dr["摄影师"].ToString());
- }
- if (!strWhereList.Contains(Convert.ToString(dr["摄影助理"].ToString())))
- {
- strWhereList.Add(dr["摄影助理"].ToString());
- }
- if (!strWhereList.Contains(Convert.ToString(dr["化妆师"].ToString())))
- {
- strWhereList.Add(dr["化妆师"].ToString());
- }
- if (!strWhereList.Contains(Convert.ToString(dr["化妆助理"].ToString())))
- {
- strWhereList.Add(dr["化妆助理"].ToString());
- }
- if (!strWhereList.Contains(Convert.ToString(dr["引导师"])))
- {
- strWhereList.Add(dr["引导师"].ToString());
- }
- if (!strWhereList.Contains(Convert.ToString(dr["引导助理"])))
- {
- strWhereList.Add(dr["引导助理"].ToString());
- }
- }
- LYFZ.BLL.BLL_ErpUser userBll = new BLL.BLL_ErpUser();
- DataTable userTb = userBll.GetList(" User_EmployeeID in ('" + string.Join("','", strWhereList.ToArray()) + "') ").Tables[0];
- foreach(DataRow dr in DataTableDb.Rows)
- {
- if(!string.IsNullOrEmpty(Convert.ToString(dr["摄影师"])))
- {
- DataRow[] tempUserRow = userTb.Select( " User_EmployeeID ='"+dr["摄影师"].ToString()+"' ");
- if(tempUserRow.Length>0)
- {
- dr["摄影师"] = tempUserRow[0]["User_Name"].ToString();
- }
- }
- if (!string.IsNullOrEmpty(Convert.ToString(dr["摄影助理"]).ToString()))
- {
- DataRow[] tempUserRow = userTb.Select(" User_EmployeeID ='" + dr["摄影助理"].ToString() + "' ");
- if (tempUserRow.Length > 0)
- {
- dr["摄影助理"] = tempUserRow[0]["User_Name"].ToString();
- }
- }
- if (!string.IsNullOrEmpty(Convert.ToString(dr["化妆师"]).ToString()))
- {
- DataRow[] tempUserRow = userTb.Select(" User_EmployeeID ='" + dr["化妆师"].ToString() + "' ");
- if (tempUserRow.Length > 0)
- {
- dr["化妆师"] = tempUserRow[0]["User_Name"].ToString();
- }
- }
- if (!string.IsNullOrEmpty(Convert.ToString(dr["化妆助理"]).ToString()))
- {
- DataRow[] tempUserRow = userTb.Select(" User_EmployeeID ='" + dr["化妆助理"].ToString() + "' ");
- if (tempUserRow.Length > 0)
- {
- dr["化妆助理"] = tempUserRow[0]["User_Name"].ToString();
- }
- }
- if (!string.IsNullOrEmpty(Convert.ToString(dr["引导师"]).ToString()))
- {
- DataRow[] tempUserRow = userTb.Select(" User_EmployeeID ='" + dr["引导师"].ToString() + "' ");
- if (tempUserRow.Length > 0)
- {
- dr["引导师"] = tempUserRow[0]["User_Name"].ToString();
- }
- }
- if (!string.IsNullOrEmpty(Convert.ToString(dr["引导助理"]).ToString()))
- {
- DataRow[] tempUserRow = userTb.Select(" User_EmployeeID ='" + dr["引导助理"].ToString() + "' ");
- if (tempUserRow.Length > 0)
- {
- dr["引导助理"] = tempUserRow[0]["User_Name"].ToString();
- }
- }
- if (!string.IsNullOrEmpty(Convert.ToString(dr["重拍责任人"]).ToString()))
- {
- DataRow[] tempUserRow = userTb.Select(" User_EmployeeID in ('" + dr["重拍责任人"].ToString() + "') ");
- string userName = "";
- foreach (DataRow tempUser in tempUserRow)
- {
- if(!string.IsNullOrEmpty(userName))
- {
- userName += ",";
- }
- userName += tempUser["User_Name"].ToString();
- }
- if (tempUserRow.Length > 0)
- {
- dr["重拍责任人"] = userName;
- }
- }
- }
- BindDataGridView(modelImagePostionAction, DataTableDb);
- }
- void BindDataGridView(ModelImagePostionAction modelImagePostionAction, DataTable DataTableDb)
- {
- Dictionary<string, decimal> dicList = new Dictionary<string, decimal>();
- if (string.IsNullOrEmpty(modelImagePostionAction.OrdType))
- {
- this.Text = modelImagePostionAction.OrdTitle;
- }
- else
- {
- this.Text = modelImagePostionAction.OrdTitle + " (" + modelImagePostionAction.OrdType + ")";
- }
- foreach (DataColumn columText in DataTableDb.Columns)
- {
- this.gridViewDetail.Columns.Add(columText.ColumnName, columText.ColumnName);
- if(columText.ColumnName=="订单号")
- {
- this.gridViewDetail.Columns[0].Width = 160;
- }
- }
- string ordNumber = "";
- bool bNowData = false;
- List<decimal> payTotalValue = new List<decimal>();
- foreach (DataRow dr in DataTableDb.Rows)
- {
- if (modelImagePostionAction.OrdTitle.Equals("营收分析"))
- {
- if (ordNumber != dr["订单号"].ToString_s())
- {
- bNowData = false;
- ordNumber = dr["订单号"].ToString_s();
- payTotalValue = new List<decimal>();
- payTotalValue.Add(Convert.ToDecimal(dr["实收"]));
- }
- else
- {
- bNowData = true;
- payTotalValue.Add(Convert.ToDecimal(dr["实收"]));
- }
- }
-
- int rowIndex = this.gridViewDetail.Rows.Add();
- if (modelImagePostionAction.OrdTitle.Equals("营收分析") )
- {
- this.gridViewDetail.Rows[rowIndex].Cells["余款"].Value = Convert.ToDecimal(dr["业绩"]) - Convert.ToDecimal(dr["实收"]);
- }
- foreach (DataColumn columText in DataTableDb.Columns)
- {
- if (modelImagePostionAction.OrdTitle.Equals("营收分析") && columText.ColumnName.Equals("余款")&& !bNowData)
- {
- continue;
- }
- this.gridViewDetail.Rows[rowIndex].Cells[columText.ColumnName].Value = dr[columText.ColumnName];
- if (modelImagePostionAction.OrdTitle.Equals("营收分析") )
- {
- if (bNowData)
- {
- if (!columText.ColumnName.Equals("付款方式") && !columText.ColumnName.Equals("实收") )
- {
- this.gridViewDetail.Rows[rowIndex].Cells[columText.ColumnName].Value = "";
- }
- decimal totalValue = payTotalValue.Sum();
- //for (int i = 0; i < payTotalValue.Count; i++)
- //{
- this.gridViewDetail.Rows[rowIndex - (payTotalValue.Count-1)].Cells["余款"].Value = Convert.ToDecimal(dr["业绩"]) - totalValue;
- //}
- }
- }
-
- /*if (dr[columText.ColumnName] != null)
- {
- if (IsNumeric(dr[columText.ColumnName].ToString()))
- {
- if (!dicList.ContainsKey(columText.ColumnName))
- {
- if (string.IsNullOrEmpty(dr[columText.ColumnName].ToString()))
- {
- dr[columText.ColumnName] = "0";
- }
- dicList.Add(columText.ColumnName, Convert.ToDecimal(dr[columText.ColumnName].ToString()));
- }
- else
- {
- if (string.IsNullOrEmpty(dr[columText.ColumnName].ToString()))
- {
- dr[columText.ColumnName] = "0";
- }
- dicList[columText.ColumnName] += Convert.ToDecimal(dr[columText.ColumnName].ToString());
- }
- }
- }*/
- }
- }
- Dictionary<string, decimal> pluAmountList = new Dictionary<string, decimal>();
- foreach(DataGridViewRow row in gridViewDetail.Rows)
- {
- foreach(DataGridViewColumn colum in gridViewDetail.Columns)
- {
- if (IsNumeric(row.Cells[colum.Name].Value.ToString()))
- {
- if (!dicList.ContainsKey(colum.Name))
- {
- if (!string.IsNullOrEmpty(row.Cells[colum.Name].Value.ToString()))
- {
- dicList.Add(colum.Name, Convert.ToDecimal(row.Cells[colum.Name].Value.ToString()));
- //row.Cells[colum.Name].Value = "0";
- }
-
- }
- else
- {
- if (!string.IsNullOrEmpty(row.Cells[colum.Name].Value.ToString()))
- {
- decimal tempValue = 0;
- if (decimal.TryParse(row.Cells[colum.Name].Value.ToString(), out tempValue))
- {
- dicList[colum.Name] += Convert.ToDecimal(row.Cells[colum.Name].Value.ToString());
- //row.Cells[colum.Name].Value = "0";
- }
- }
-
- }
- if(colum.Name=="加挑金额")
- {
- if (gridViewDetail.Columns.Contains("订单号"))
- {
- if(!pluAmountList.ContainsKey(row.Cells["订单号"].Value.ToString_s()))
- {
- pluAmountList.Add(row.Cells["订单号"].Value.ToString_s(), Convert.ToDecimal(row.Cells["加挑金额"].Value.ToString_s()));
- }
- }
- }
- }
- }
- }
- if(dicList.ContainsKey("加挑金额"))
- {
- dicList["加挑金额"] = pluAmountList.Values.Sum();
- }
- string msg = "";
- foreach (string key in dicList.Keys)
- {
- if (!string.IsNullOrEmpty(msg))
- {
- msg += " ";
- }
- msg += key + ":" + dicList[key];
- }
- labelMsg.Text = msg;
- }
- public bool IsNumeric(string value)
- {
- return Regex.IsMatch(value, @"^[+-]?\d*[.]?\d*$");
- }
- }
- }
|