public static bool ImportCust(string importFile, string SheetName) { DataTable dt = GetExcelFileData(importFile, SheetName).Tables[0]; try { //清除TA Customer中的数据 new OnLoadSystemCommonData().GetTACust(); foreach (var taCust in CommonData.TaCustList) { _control.DeleteEntity(taCust); } //添加数据 foreach (DataRow item in dt.Rows) { if (!string.IsNullOrEmpty(item[0].ToString()) && !string.IsNullOrEmpty(item[1].ToString()) && !string.IsNullOrEmpty(item[2].ToString()) && !string.IsNullOrEmpty(item[3].ToString()) && !string.IsNullOrEmpty(item[4].ToString()) && !string.IsNullOrEmpty(item[5].ToString()) && !string.IsNullOrEmpty(item[6].ToString())) { TACustInfo taCustInfo = new TACustInfo(); taCustInfo.SystemKey = Guid.NewGuid(); taCustInfo.Phone1 = item[0].ToString(); taCustInfo.Name = item[1].ToString(); taCustInfo.Address1 = item[2].ToString(); taCustInfo.Postcode1 = item[3].ToString(); taCustInfo.Distance = item[4].ToString(); taCustInfo.PcZone = item[5].ToString(); taCustInfo.IsBlackListed = item[6].ToString().ToUpper().Equals("YES") ? "Y" : "N"; _control.AddEntity(taCustInfo); } } return(true); } catch (Exception ex) { // MessBox.Show(""); string aa = ex.Message; return(false); } }
private void FrmTAPay_Load(object sender, EventArgs e) { OnLoadSystemCommonData onLoadSystemCommonData = new OnLoadSystemCommonData(); onLoadSystemCommonData.GetTAPayType(); onLoadSystemCommonData.GetTAOrderItem(); onLoadSystemCommonData.GetTAPaymentList(); if (string.IsNullOrEmpty(strMenuID)) { strMenuID = CommonData.TaMenuSetList.FirstOrDefault().SystemKey.ToString(); } strCtlName = "txtPay1"; #region 各种附件事件 btn0.Click += BtnNum_Click; btn1.Click += BtnNum_Click; btn2.Click += BtnNum_Click; btn3.Click += BtnNum_Click; btn4.Click += BtnNum_Click; btn5.Click += BtnNum_Click; btn6.Click += BtnNum_Click; btn7.Click += BtnNum_Click; btn8.Click += BtnNum_Click; btn9.Click += BtnNum_Click; btnPoint.Click += BtnNum_Click; txtPay1.MouseDown += txtPay_Click; txtPay2.MouseDown += txtPay_Click; txtPay3.MouseDown += txtPay_Click; txtPay4.MouseDown += txtPay_Click; btnDriver1.Click += BtnDriver_Click; btnDriver2.Click += BtnDriver_Click; btnDriver3.Click += BtnDriver_Click; btnDriver4.Click += BtnDriver_Click; btnDriver5.Click += BtnDriver_Click; btnDriver6.Click += BtnDriver_Click; #endregion #region 查询会员 //查询会员 new OnLoadSystemCommonData().GetTACust(); var custList = CommonData.TaCustList.Where(s => s.SystemKey.ToString().Equals(CustNum)); if (custList.Any()) { TACustInfo taCustInfo = custList.FirstOrDefault(); txtPhone.Text = taCustInfo.Phone1; txtName.Text = taCustInfo.Name; txtHouseNo.Text = taCustInfo.HouseNo; txtAddress.Text = taCustInfo.Address1; txtPostcode.Text = taCustInfo.Postcode1; txtDistance.Text = taCustInfo.Distance; txtPCZone.Text = taCustInfo.PcZone; txtDelCharge.Text = taCustInfo.DelCharge; txtReadyTime.Text = taCustInfo.ReadyTime; txtIntNotes.Text = taCustInfo.IntNotes; txtNotes.Text = taCustInfo.NotesOnBill; chkBlackListed.Checked = taCustInfo.IsBlackListed.Equals("Y"); } #endregion #region Delivery / Collection Note new OnLoadSystemCommonData().GetTAPreDefined(); var cmbList = CommonData.TaPreDefinedList.Select(lstPD => new { Prevalue = lstPD.PreTxtValue }); cmbNote.DataSource = cmbList.ToList(); cmbNote.ValueMember = "Prevalue"; cmbNote.DisplayMember = "Prevalue"; #endregion #region 控件数组 lblPayType[0] = lblPayType1; lblPayType[1] = lblPayType2; lblPayType[2] = lblPayType3; lblPayType[3] = lblPayType4; txtPay[0] = txtPay1; txtPay[1] = txtPay2; txtPay[2] = txtPay3; txtPay[3] = txtPay4; lblPaySurcharge[0] = lblSurcharge1; lblPaySurcharge[1] = lblSurcharge2; lblPaySurcharge[2] = lblSurcharge3; lblPaySurcharge[3] = lblSurcharge4; btnDriver[0] = btnDriver1; btnDriver[1] = btnDriver2; btnDriver[2] = btnDriver3; btnDriver[3] = btnDriver4; btnDriver[4] = btnDriver5; btnDriver[5] = btnDriver6; lblSCharge[0] = lblSCharge1; lblSCharge[1] = lblSCharge2; lblSCharge[2] = lblSCharge3; lblSCharge[3] = lblSCharge4; //付款 int i = 0; foreach (var taPayTypeInfo in CommonData.TaPayTypeList) { if (i >= 4) { break; } lblSCharge[i].Visible = true; lblPaySurcharge[i].Visible = true; lblPaySurcharge[i].Text = "0.00"; txtPay[i].Visible = true; lblPayType[i].Visible = true; lblPayType[i].Text = taPayTypeInfo.PaymentType; i++; } for (int j = i + 1; j <= 3; j++) { lblSCharge[j].Visible = false; lblPaySurcharge[j].Visible = false; txtPay[j].Visible = false; lblPayType[j].Visible = false; } #region 司机清单 //司机清单 if (!string.IsNullOrEmpty(GetWeek(DateTime.Today.DayOfWeek.ToString()))) { i = 0; foreach ( var driverSet in CommonData.TaDriverSetUpList.Where( s => s.DriverWorkDay.Contains(GetWeek(DateTime.Today.DayOfWeek.ToString()))) .TakeWhile(driverSet => i < 6)) { btnDriver[i].Text = driverSet.DriverName; } for (int j = i + 1; j < btnDriver.Length; j++) { btnDriver[j].Visible = false; } } #endregion #endregion #region 查询账单 if (CommonData.TAPaymentList.Any(s => s.ChkNum.Equals(chkNum) && s.IsPaid.Equals("N"))) { var payList = CommonData.TAPaymentList.Where(s => s.ChkNum.Equals(chkNum) && s.IsPaid.Equals("N")); TAPaymentInfo taPaymentInfo = payList.FirstOrDefault(); txtDiscount.Text = taPaymentInfo.Discount; txtSurcharge.Text = taPaymentInfo.Surcharge; txtTotal.Text = taPaymentInfo.Total; txtNotPaid.Text = taPaymentInfo.NotPaid; txtDelivery.Text = taPaymentInfo.Delivery; txtTendered.Text = taPaymentInfo.Tendered; txtToPay.Text = Convert.ToDecimal(taPaymentInfo.Total) > Convert.ToDecimal(taPaymentInfo.Tendered) ? (Convert.ToDecimal(taPaymentInfo.Total) - Convert.ToDecimal(taPaymentInfo.Tendered)).ToString() : "0.00"; AcctPay = Convert.ToDecimal(taPaymentInfo.AcctPay); if (lblSCharge[0].Visible) { txtPay[0].Text = taPaymentInfo.PayType1; lblPaySurcharge[0].Text = taPaymentInfo.PayTypeSurCharge1; } if (lblSCharge[1].Visible) { txtPay[1].Text = taPaymentInfo.PayType2; lblPaySurcharge[1].Text = taPaymentInfo.PayTypeSurCharge2; } if (lblSCharge[2].Visible) { txtPay[2].Text = taPaymentInfo.PayType3; lblPaySurcharge[2].Text = taPaymentInfo.PayTypeSurCharge3; } if (lblSCharge[3].Visible) { txtPay[3].Text = taPaymentInfo.PayType4; lblPaySurcharge[3].Text = taPaymentInfo.PayTypeSurCharge4; } GetAmount(); } else { return; } #endregion }