/// <summary> /// 加载页面数据 /// </summary> private void LoadData() { switch (Actions) { case WebAction.Add: break; case WebAction.Edit: if (CustomerPrice != null) { txtFCode.Text = CustomerPrice.FCode; tbxFCustomer.Text = CustomerService.FirstOrDefault(p => p.FCode == CustomerPrice.FCode && // p.FCompanyId == CurrentUser.AccountComId).FName; txtFItemCode.Text = CustomerPrice.FItemCode; tbxFName.Text = ItemsService.FirstOrDefault(p => p.FCode == CustomerPrice.FItemCode && // p.FCompanyId == CurrentUser.AccountComId).FName; txtFMemo.Text = CustomerPrice.FMemo; txtFPrice.Text = CustomerPrice.FPrice.ToString(); dateBegin.SelectedDate = CustomerPrice.FBeginDate; } break; } }
protected void btnSubmit_Click(object sender, EventArgs e) { bool isSucceed = false; try { var codes = FCodes.Split(','); foreach (var code in codes) { if (!string.IsNullOrEmpty(code)) { var ftx = ItemsService.FirstOrDefault( p => p.FCompanyId == CurrentUser.AccountComId && p.FCode == code); ftx.FSubCateId = ddlFSubCate.SelectedValue; ftx.FSubCateName = ddlFSubCate.SelectedText; ItemsService.SaveChanges(); } } isSucceed = true; } catch (Exception) { isSucceed = false; } finally { if (isSucceed) { PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } else { Alert.Show("提交失败!", MessageBoxIcon.Error); } } }
/// <summary> /// 禁用/启用 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnEnabled_Click(object sender, EventArgs e) { try { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.Show("请至少选择一项!", MessageBoxIcon.Information); } else if (Grid1.SelectedRowIndexArray.Length > 1) { Alert.Show("只能选择一项!", MessageBoxIcon.Information); } else { string sid = Grid1.DataKeys[Grid1.SelectedRowIndexArray[0]][0].ToString(); var customer = ItemsService.FirstOrDefault(p => p.FCode == sid); customer.FFlag = customer.FFlag == 1 ? 0 : 1; if (ItemsService.SaveChanges() > 0) { BindDataGrid(); Alert.Show("提交成功。", MessageBoxIcon.Information); //记录日志 Log(string.Format(@"禁用帐号{0}成功。", sid)); } else { Alert.Show("提交失败,请重试!", MessageBoxIcon.Error); } } } catch (Exception) { Alert.Show("删除失败!", MessageBoxIcon.Warning); } }
/// <summary> /// ModifiedGrid /// </summary> private void ModifiedGrid() { //编辑行事件 var dictModified = Grid1.GetModifiedDict(); foreach (var rowKey in dictModified.Keys) { string datakey = Grid1.DataKeys[rowKey][0].ToString(); var sKeys = new StringBuilder(); var sValues = new StringBuilder(); foreach (var key in dictModified[rowKey].Keys) { sKeys.AppendFormat("{0},", key); } foreach (var dictValue in dictModified[rowKey].Values) { sValues.AppendFormat("{0},", dictValue); } if (sValues.ToString().Contains("-1")) { Alert.Show("请输入有效信息!", MessageBoxIcon.Warning); return; } var details = LiquidPlanService.Where(p => p.KeyId == datakey && p.FCompanyId == CurrentUser.AccountComId).FirstOrDefault(); var keys = sKeys.ToString().Split(','); var values = sValues.ToString().Split(','); for (int i = 0; i < keys.Count(); i++) { #region 修改内容 var key = keys[i]; var value = values[i]; if (!string.IsNullOrEmpty(key) && key.Length > 0) { if (details != null) { #region Edit if (key.Equals("KeyId")) { details.KeyId = value; } if (key.Equals("FDate")) { details.FDate = Convert.ToDateTime(value); } if (key.Equals("FItemName"))//产品 { details.FItemCode = value; if (!string.IsNullOrEmpty(value)) { details.FItemName = ItemsService.FirstOrDefault( p => p.FCode == value && p.FCompanyId == CurrentUser.AccountComId).FName; } } if (key.Equals("FBill")) { details.FBill = value; } //if (key.Equals("FDriver")) //{ // details.FDriver = value; //} if (key.Equals("FSupercargo")) { details.FSupercargo = value; } if (key.Equals("FVehicleNum")) { details.FVehicleNum = value; if (value != null && !string.IsNullOrEmpty(value)) { var vehicle = new VehicleService().FirstOrDefault(p => p.FNum == value); details.FMargin = Convert.ToDecimal(vehicle.FMargin); } } //if (key.Equals("FMargin")) //{ // details.FMargin = Convert.ToDecimal(value); //} if (key.Equals("FPurchasedDate")) { details.FPurchasedDate = value; } if (key.Equals("FSupplierName")) { details.FSupplierCode = value; if (!string.IsNullOrEmpty(value)) { details.FSupplierName = SupplierService.FirstOrDefault( p => p.FCode == value && p.FCompanyId == CurrentUser.AccountComId).FName; } } if (key.Equals("FPurchasedPrice")) { details.FPurchasedPrice = Convert.ToDecimal(value); } if (key.Equals("FPurchasedQty")) { details.FPurchasedQty = Convert.ToDecimal(value); } if (key.Equals("FPurchasedPQty")) { details.FPurchasedPQty = Convert.ToDecimal(value); } //-------------------------------------- if (key.Equals("FDate1")) { details.FDate1 = Convert.ToDateTime(value); } if (key.Equals("FName1")) { details.FCode1 = value; if (!string.IsNullOrEmpty(value)) { details.FName1 = CustomerService.FirstOrDefault( p => p.FCode == value && p.FCompanyId == CurrentUser.AccountComId).FName; } } if (key.Equals("FPrice1")) { details.FPrice1 = Convert.ToDecimal(value); } if (key.Equals("FPQty1")) { details.FPQty1 = Convert.ToDecimal(value); } if (key.Equals("FQty1")) { details.FQty1 = Convert.ToDecimal(value); } //-------------------- if (key.Equals("FDate2")) { details.FDate2 = Convert.ToDateTime(value); } if (key.Equals("FName2")) { details.FCode2 = value; if (!string.IsNullOrEmpty(value)) { details.FName2 = CustomerService.FirstOrDefault( p => p.FCode == value && p.FCompanyId == CurrentUser.AccountComId).FName; } } if (key.Equals("FPrice2")) { details.FPrice2 = Convert.ToDecimal(value); } if (key.Equals("FQty2")) { details.FQty2 = Convert.ToDecimal(value); } if (key.Equals("FPQty2")) { details.FPQty2 = Convert.ToDecimal(value); } //-------------------- if (key.Equals("FDat3")) { details.FDate3 = Convert.ToDateTime(value); } if (key.Equals("FName3")) { details.FCode3 = value; if (!string.IsNullOrEmpty(value)) { details.FName3 = CustomerService.FirstOrDefault( p => p.FCode == value && p.FCompanyId == CurrentUser.AccountComId).FName; } } if (key.Equals("FPrice3")) { details.FPrice3 = Convert.ToDecimal(value); } if (key.Equals("FPQty3")) { details.FPQty3 = Convert.ToDecimal(value); } if (key.Equals("FQty3")) { details.FQty3 = Convert.ToDecimal(value); } //-------------------- if (key.Equals("FMarginEnd")) { details.FMarginEnd = Convert.ToDecimal(value); } if (key.Equals("FMemo")) { details.FMemo = value; } #endregion } } #endregion } LiquidPlanService.SaveChanges(); var parms = new Dictionary <string, object>(); parms.Clear(); parms.Add("@companyId", CurrentUser.AccountComId); parms.Add("@keyid", datakey); SqlService.ExecuteProcedureCommand("proc_LiquidMargin", parms); } }
/// <summary> /// AddListGrid /// </summary> private void AddListGrid() { //新增行事件 var dictList = Grid1.GetNewAddedList(); foreach (var rowKey in dictList) { var sKeys = new StringBuilder(); var sValues = new StringBuilder(); foreach (var key in rowKey.Keys) { sKeys.AppendFormat("{0},", key); } foreach (var dictValue in rowKey.Values) { sValues.AppendFormat("{0},", dictValue); } var keys = sKeys.ToString().Split(','); var values = sValues.ToString().Split(','); var details = new LHLiquidPlan(); for (int i = 0; i < keys.Count(); i++) { #region 修改内容 var key = keys[i]; var value = values[i]; if (!string.IsNullOrEmpty(key) && key.Length > 0) { if (details != null) { #region Add if (key.Equals("KeyId")) { details.KeyId = value; } if (key.Equals("FDate")) { details.FDate = Convert.ToDateTime(value); } if (key.Equals("FItemName"))//产品 { details.FItemCode = value; if (!string.IsNullOrEmpty(value)) { details.FItemName = ItemsService.FirstOrDefault( p => p.FCode == value && p.FCompanyId == CurrentUser.AccountComId).FName; } } if (key.Equals("FBill")) { details.FBill = value; } //if (key.Equals("FDriver")) //{ // details.FDriver = value; //} if (key.Equals("FSupercargo")) { details.FSupercargo = value; } if (key.Equals("FVehicleNum")) { details.FVehicleNum = value; if (value != null && !string.IsNullOrEmpty(value)) { var vehicle = new VehicleService().FirstOrDefault(p => p.FNum == value); details.FMargin = Convert.ToDecimal(vehicle.FMargin); } } //if (key.Equals("FMargin")) //{ // details.FMargin = Convert.ToDecimal(value); //} if (key.Equals("FPurchasedDate")) { details.FPurchasedDate = value; } if (key.Equals("FSupplierName")) { details.FSupplierCode = value; if (!string.IsNullOrEmpty(value)) { details.FSupplierName = SupplierService.FirstOrDefault( p => p.FCode == value && p.FCompanyId == CurrentUser.AccountComId).FName; } } if (key.Equals("FPurchasedPrice")) { details.FPurchasedPrice = Convert.ToDecimal(value); details.FAmt = details.FPurchasedPrice * details.FPurchasedQty; } if (key.Equals("FPurchasedQty")) { details.FPurchasedQty = Convert.ToDecimal(value); details.FAmt = details.FPurchasedPrice * details.FPurchasedQty; } //-------------------------------------- if (key.Equals("FDate1")) { details.FDate1 = Convert.ToDateTime(value); } if (key.Equals("FName1")) { details.FCode1 = value; if (!string.IsNullOrEmpty(value)) { details.FName1 = CustomerService.FirstOrDefault( p => p.FCode == value && p.FCompanyId == CurrentUser.AccountComId).FName; } } if (key.Equals("FPrice1")) { details.FPrice1 = Convert.ToDecimal(value); details.FAmt1 = details.FPrice1 * details.FQty1; } if (key.Equals("FQty1")) { details.FQty1 = Convert.ToDecimal(value); details.FAmt1 = details.FPrice1 * details.FQty1; } //-------------------- if (key.Equals("FDate2")) { details.FDate2 = Convert.ToDateTime(value); } if (key.Equals("FName2")) { details.FCode2 = value; if (!string.IsNullOrEmpty(value)) { details.FName2 = CustomerService.FirstOrDefault( p => p.FCode == value && p.FCompanyId == CurrentUser.AccountComId).FName; } } if (key.Equals("FPrice2")) { details.FPrice2 = Convert.ToDecimal(value); details.FAmt2 = details.FPrice2 * details.FQty2; } if (key.Equals("FQty2")) { details.FQty2 = Convert.ToDecimal(value); details.FAmt2 = details.FPrice2 * details.FQty2; } //-------------------- if (key.Equals("FDat3")) { details.FDate3 = Convert.ToDateTime(value); } if (key.Equals("FName3")) { details.FCode3 = value; if (!string.IsNullOrEmpty(value)) { details.FName3 = CustomerService.FirstOrDefault( p => p.FCode == value && p.FCompanyId == CurrentUser.AccountComId).FName; } } if (key.Equals("FPrice3")) { details.FPrice3 = Convert.ToDecimal(value); details.FAmt3 = details.FPrice3 * details.FQty3; } if (key.Equals("FQty3")) { details.FQty3 = Convert.ToDecimal(value); details.FAmt3 = details.FPrice3 * details.FQty3; } //-------------------- if (key.Equals("FMarginEnd")) { details.FMarginEnd = Convert.ToDecimal(value); } if (key.Equals("FMemo")) { details.FMemo = value; } #endregion } } #endregion } string keyId = SequenceService.CreateSequence(Convert.ToDateTime(details.FDate), "LP", CurrentUser.AccountComId); details.KeyId = keyId; details.FDeleteFlag = 0; details.FType = 26; details.FFlag = 1; details.CreateBy = CurrentUser.AccountName; details.FStatus = 10; details.FCompanyId = CurrentUser.AccountComId; LiquidPlanService.Add(details); var refuel = new LHLiquidRefuel { FFlag = 1, CreateBy = CurrentUser.AccountName, FDate = details.FDate, KeyId = details.KeyId, FCompanyId = CurrentUser.AccountComId }; LiquidRefuelService.Add(refuel); } Grid1.CommitChanges(); }