private void btnModifyPaid_Click(object sender, EventArgs e) { try { int ret = 0; string isPaid = ""; if (cbIsPaid.Checked == true) { isPaid = "已付款"; ret = new T_ExpenseAllocationTableAdapter().UpdateIsPaid(isPaid, dtpPaidDate.Value, ExId); } else { isPaid = "未付款"; ret = new T_ExpenseAllocationTableAdapter().UpdateIsPaid(isPaid, null, ExId); } if (ret > 0) { MessageBox.Show("付款信息修改成功"); } else { MessageBox.Show("付款信息修改失败"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void SetTableNo() { if (type == "个人订单" || type == "部门订单" || type == "跨区域订单") { if (oldType == "个人订单" || oldType == "部门订单" || oldType == "跨区域订单") { txtTableNo.Text = FailTableNo; return; } } else { if (oldType == "公司跟单") { txtTableNo.Text = FailTableNo; return; } } if (SalerId > 0) { string mTableNo; if (DeliverDate.Year.ToString() == "1") { mTableNo = DateTime.Now.Year.ToString("0000") + DateTime.Now.Month.ToString("00"); } else { mTableNo = DeliverDate.Year.ToString("0000") + DeliverDate.Month.ToString("00"); } var mTable = new T_UsersTableAdapter().GetDataById(SalerId); if (mTable.Rows.Count > 0) { 销售管理.DAL.DataSetUsers.T_UsersRow mRow = mTable[0]; string mSalerChar = mRow.UserChar; if (type == "个人订单" || type == "部门订单" || type == "跨区域订单") { mTableNo = "RT-" + mSalerChar + mTableNo; if (mSalerChar == "") { MessageBox.Show("请设置个人区域代码"); btnApply.Enabled = false; } } else { mTableNo = "RT-" + mTableNo; } string mTable1 = new T_ExpenseAllocationTableAdapter().GetMaxTableNo(mTableNo).ToString(); txtTableNo.Text = mTableNo + (Convert.ToInt32(mTable1.Substring(mTable1.Length - 3, 3)) + 1).ToString("000"); } } }
public DateTime DeliverDate; //发货日期 private void 申请费用分配_Load(object sender, EventArgs e) { rbPersonal.Checked = true; isLoading = true; if (ExId > -1) //如果费用分配ID大于-1,查看费用分配信息 { DataTable mTable1 = new T_ExpenseAllocationTableAdapter().GetDataById(ExId); if (mTable1.Rows.Count > 0) { var mDataRow = (销售管理.DAL.DataSetExpenseAllocation.T_ExpenseAllocationRow)mTable1.Rows[0]; //cmbMonth.SelectedItem = mDataRow.Month; //txtTableNo.Text = mDataRow.TableNo; //txtCustomerName.Text = mDataRow.CustomerName; txtProjectName.Text = mDataRow.ProjectName; var mProductTable = new T_ProductsTableAdapter().GetDataByID(mDataRow.ProductName); if (mProductTable.Rows.Count > 0) { txtProductName.Text = mProductTable[0].Name; } var mCustomerTable = new T_CustomersTableAdapter().GetDataById(Convert.ToInt64(mDataRow.CustomerName)); if (mProductTable.Rows.Count > 0) { txtCustomerName.Text = mCustomerTable[0].CompanyName; } var mSaleDetailsTable = new T_SaleDetailsTableAdapter().GetDataByExId(ExId); if (mSaleDetailsTable.Rows.Count > 0) { DeliverDate = mSaleDetailsTable[0].SaleDate; } txtProductName.Tag = mDataRow.ProductName; txtCustomerName.Tag = mDataRow.CustomerName; txtType.Text = mDataRow.ProductType; txtAmount.Text = mDataRow.Amount.ToString(); txtDeliverPrice.Text = mDataRow.DeliverPrice.ToString(); txtDeliverSum.Text = mDataRow.DeliverSum.ToString(); txtSalePrice.Text = mDataRow.SalePrice.ToString(); txtSaleSum.Text = mDataRow.SaleSum.ToString(); txtSaleWages.Text = mDataRow.SaleWages.ToString(); txtCommissionPrice.Text = mDataRow.CommissionPrice.ToString(); txtCommissionSum.Text = mDataRow.CommissionSum.ToString(); txtSaleCommission.Text = mDataRow.SaleComission.ToString(); txtAgentPrice.Text = mDataRow.AgentPrice.ToString(); txtAgentSum.Text = mDataRow.AgentSum.ToString(); txtAgentCommission.Text = mDataRow.AgentCommission.ToString(); SalerId = mDataRow.UserName; DataTable mTable = new T_UsersTableAdapter().GetDataById(SalerId); if (mTable.Rows.Count > 0) { var mDataRow1 = (销售管理.DAL.DataSetUsers.T_UsersRow)mTable.Rows[0]; txtUserName.Text = mDataRow1.UserName; } if (mDataRow.type == "个人订单") { rbPersonal.Checked = true; } else if (mDataRow.type == "部门订单") { rbDepart.Checked = true; } else if (mDataRow.type == "公司跟单") { rbCompany.Checked = true; } else { rbCity.Checked = true; } if (mDataRow.IsCitySalerNull() == false) { if (mDataRow.CitySaler != "0") { cmbUserName.SelectedValue = Convert.ToInt64(mDataRow.CitySaler); } } txtCitySum.Text = mDataRow.CitySum; txtCityWages.Text = mDataRow.CityWages; if (mDataRow.IsCitySalePriceNull() == false) { txtCitySalePrice.Text = mDataRow.CitySalePrice.ToString(); } if (mDataRow.IsCitySaleSumNull() == false) { txtCitySaleSum.Text = mDataRow.CitySaleSum.ToString(); } if (mDataRow.IsCitySaleCommissionNull() == false) { txtCitySaleCommission.Text = mDataRow.CitySaleCommission.ToString(); } oldType = mDataRow.type; FailTableNo = mDataRow.TableNo; txtTableNo.Text = mDataRow.TableNo; if (mDataRow.IsPaid == "已付款") { cbIsPaid.Checked = true; if (mDataRow.IsPaidDateNull() == false) { dtpPaidDate.Value = mDataRow.PaidDate; } } else { cbIsPaid.Checked = false; } if (mDataRow.IsHasTaxNull() == false) { if (mDataRow.HasTax == "含税") { cbTax.Checked = true; } else { cbTax.Checked = false; } } else { cbTax.Checked = false; } txtStatus.Text = mDataRow.Status;//+"。" + mDataRow.BusinessRemark; labStatus.Visible = true; txtStatus.Visible = true; btnApply.Enabled = false; //label12.Visible = true; //dtpPaidDate.Visible = true; cbIsPaid.Visible = true; if (mDataRow.Status.Contains("不通过") == true && isModify == true) { btnApply.Enabled = true; btnApply.Text = "重新申请"; cbIsPaid.Visible = false; } else { btnApply.Enabled = false; } //groupBox1.Enabled = false; } else { MessageBox.Show("该费用分配表号不存在"); this.Close(); return; } if (Classes.PubClass.UserRight == "领导" || Classes.PubClass.UserRight == "超级管理员" || Classes.PubClass.UserRight == "商务经理") { btnModifyPaid.Visible = true; } else { btnModifyPaid.Visible = false; } } else //申请费用分配 if (mRow != null) { DeliverDate = Convert.ToDateTime(mRow.Cells["saleDateDataGridViewTextBoxColumn"].Value); txtCustomerName.Text = mRow.Cells["customerNameDataGridViewTextBoxColumn"].Value.ToString(); txtProductName.Text = mRow.Cells["productNameDataGridViewTextBoxColumn"].Value.ToString(); txtAmount.Text = mRow.Cells["amountDataGridViewTextBoxColumn"].Value.ToString(); //cmbMonth.SelectedItem = mRow.Cells["saleMonthDataGridViewTextBoxColumn"].Value.ToString(); txtDeliverPrice.Text = mRow.Cells["priceDataGridViewTextBoxColumn"].Value.ToString(); long SaleDetailsId = Convert.ToInt64(mRow.Cells["idDataGridViewTextBoxColumn"].Value); var SaleDetailsTable = new T_SaleDetailsTableAdapter().GetDataById(SaleDetailsId); if (SaleDetailsTable.Rows.Count > 0) { txtProductName.Tag = SaleDetailsTable[0].ProductName; txtCustomerName.Tag = SaleDetailsTable[0].CustomerName; SalerId = SaleDetailsTable[0].UserName; var mUserTable = new T_UsersTableAdapter().GetDataById(SalerId); if (mUserTable.Rows.Count > 0) { txtUserName.Text = mUserTable[0].UserName; } SetTableNo(); } btnModifyPaid.Visible = false; } isLoading = false; }
private void button1_Click(object sender, EventArgs e) { //try //{ // decimal deliverPrice=0, salePrice=0, commissionPrice=0, agentPrice=0, deliverSum=0, SaleSum=0, saleWages=0, commissionSum=0, saleCommission=0, agentSum=0, agentCommission=0; // long Amount; // Amount = Convert.ToInt64(txtAmount.Text); // deliverPrice = Convert.ToDecimal(txtDeliverPrice.Text); //发货单价 // deliverSum = deliverPrice * Amount; //发货额 // txtDeliverSum.Text = deliverSum.ToString("0.00"); // salePrice = Convert.ToDecimal(txtSalePrice.Text); //销售单价 // SaleSum = salePrice * Amount; //销售额 // txtSaleSum.Text = SaleSum.ToString("0.00"); // saleWages = SaleSum / 100; //销售工资 // txtSaleWages.Text = saleWages.ToString("0.00"); // commissionPrice = Convert.ToDecimal(txtCommissionPrice.Text);//提成单价 // commissionSum = commissionPrice * Amount; //提成销售额 // txtCommissionSum.Text = commissionSum.ToString(); // saleCommission = (commissionSum / (decimal)1.17) / 5; //销售提成 // txtSaleCommission.Text = saleCommission.ToString("0.00"); // //agentPrice = Convert.ToDecimal(txtAgentPrice.Text); //代理商单价 // //agentSum = agentPrice * Amount; //代理商额度 // //txtAgentSum.Text = agentSum.ToString("0.00"); // //agentCommission = agentSum / (decimal)1.25; //代理商税后佣金 // //txtAgentCommission.Text = agentCommission.ToString("0.00"); // if (string.IsNullOrEmpty(txtAgentPrice.Text) == true) txtAgentPrice.Text = "0"; //代理商单价为空则置0 // agentPrice = Convert.ToDecimal(txtAgentPrice.Text); //代理商单价 // agentSum = agentPrice * Amount; //代理商额度 // txtAgentSum.Text = agentSum.ToString("0.00"); // if (rbCompany.Checked == true) // { // //公司跟单 // if (cbTax.Checked == true) // { // //销售含税 // agentCommission = agentSum * (decimal)0.75; //代理商税后佣金 // txtAgentCommission.Text = agentCommission.ToString("0.00"); // } // else // { // //销售不含税 // txtAgentCommission.Text = txtAgentSum.Text; // } // } // else // { // //个人订单\部门订单\跨区域订单 // agentCommission = agentSum / (decimal)1.25; //代理商税后佣金 // txtAgentCommission.Text = agentCommission.ToString("0.00"); // } // if (deliverPrice < salePrice + commissionPrice + agentPrice) // { // MessageBox.Show("销售单价、提成单价、代理商单价之和不能大于发货单价"); // return; // } // string isPaid,hasTax; // object ret; // if (cbTax.Checked == true) // { // hasTax = "含税"; // } // else // { // hasTax = "不含税"; // } // if (cbIsPaid.Checked == true) // { // isPaid = "已付款"; // //ret = new T_ExpenseAllocationTableAdapter().MyInsert("", SalerId, txtTableNo.Text, Convert.ToInt64(txtCustomerName.Tag), txtProjectName.Text, Convert.ToInt64(txtProductName.Tag), txtType.Text, Amount, deliverPrice, Math.Round(deliverSum, 2), salePrice, Math.Round(SaleSum, 2), 0, Math.Round(saleWages, 2), commissionPrice, Math.Round(commissionSum, 2), Math.Round(saleCommission, 2), agentPrice, Math.Round(agentSum, 2), Math.Round(agentCommission, 2), isPaid, dtpPaidDate.Value, "已提交等待商务审核", null, null, null, null, null, null, null, null, null, Convert.ToInt64(mRow.Cells["idDataGridViewTextBoxColumn"].Value), type, Convert.ToInt64(cmbUserName.SelectedValue), Convert.ToDecimal(txtCitySum.Text == "" ? "0" : txtCitySum.Text), Convert.ToDecimal(txtCityWages.Text == "" ? "0" : txtCityWages.Text),hasTax); // } // else // { // isPaid = "未付款"; // //ret = new T_ExpenseAllocationTableAdapter().MyInsert("", SalerId, txtTableNo.Text, Convert.ToInt64(txtCustomerName.Tag), txtProjectName.Text, Convert.ToInt64(txtProductName.Tag), txtType.Text, Amount, deliverPrice, Math.Round(deliverSum, 2), salePrice, Math.Round(SaleSum, 2), 0, Math.Round(saleWages, 2), commissionPrice, Math.Round(commissionSum, 2), Math.Round(saleCommission, 2), agentPrice, Math.Round(agentSum, 2), Math.Round(agentCommission, 2), isPaid, null, "已提交等待商务审核", null, null, null, null, null, null, null, null, null, Convert.ToInt64(mRow.Cells["idDataGridViewTextBoxColumn"].Value), type, Convert.ToInt64(cmbUserName.SelectedValue), Convert.ToDecimal(txtCitySum.Text == "" ? "0" : txtCitySum.Text), Convert.ToDecimal(txtCityWages.Text == "" ? "0" : txtCityWages.Text),hasTax); // } // ret = new T_ExpenseAllocationTableAdapter().MyInsert("", SalerId, txtTableNo.Text, Convert.ToInt64(txtCustomerName.Tag), txtProjectName.Text, Convert.ToInt64(txtProductName.Tag), txtType.Text, Amount, deliverPrice, Math.Round(deliverSum, 2), salePrice, Math.Round(SaleSum, 2), 0, Math.Round(saleWages, 2), commissionPrice, Math.Round(commissionSum, 2), Math.Round(saleCommission, 2), agentPrice, Math.Round(agentSum, 2), Math.Round(agentCommission, 2), isPaid, null, "已提交等待商务审核", null, null, null, null, null, null, null, null, null, Convert.ToInt64(mRow.Cells["idDataGridViewTextBoxColumn"].Value), type, Convert.ToInt64(cmbUserName.SelectedValue), Convert.ToDecimal(txtCitySum.Text == "" ? "0" : txtCitySum.Text), Convert.ToDecimal(txtCityWages.Text == "" ? "0" : txtCityWages.Text), hasTax); // if ((long)ret > 0) // { // ret = new T_SaleDetailsTableAdapter().UpdateExById(ret.ToString(), Convert.ToInt64(mRow.Cells["idDataGridViewTextBoxColumn"].Value)); // MessageBox.Show("已提交"); // btnApply.Enabled = false; // } // else // { // MessageBox.Show("提交失败"); // } //} //catch (Exception ex) //{ // MessageBox.Show(ex.Message); //} //this.DialogResult = System.Windows.Forms.DialogResult.OK; try { decimal deliverPrice = 0, salePrice = 0, commissionPrice = 0, agentPrice = 0, deliverSum = 0, SaleSum = 0, DepartSum = 0, saleWages = 0, commissionSum = 0, saleCommission = 0, agentSum = 0, agentCommission = 0, citySalePrice = 0, citySaleSum = 0, citySaleCommission = 0; long Amount; if (string.IsNullOrEmpty(txtAgentPrice.Text) == true) { txtAgentPrice.Text = "0"; //代理商单价为空则置0 } if (ComputeNums() == 1) { return; //计算 异常则退出 } Amount = Convert.ToInt64(txtAmount.Text); deliverPrice = Convert.ToDecimal(txtDeliverPrice.Text); //发货单价 deliverSum = Convert.ToDecimal(txtDeliverSum.Text); //发货额 salePrice = Convert.ToDecimal(txtSalePrice.Text); //销售单价 SaleSum = Convert.ToDecimal(txtSaleSum.Text); //销售额 DepartSum = Convert.ToDecimal(txtDepartSum.Text); //部门销售额 saleWages = Convert.ToDecimal(txtSaleWages.Text); //销售工资 commissionPrice = Convert.ToDecimal(txtCommissionPrice.Text); //提成单价 commissionSum = Convert.ToDecimal(txtCommissionSum.Text); //提成销售额 saleCommission = Convert.ToDecimal(txtSaleCommission.Text); //销售提成 agentPrice = Convert.ToDecimal(txtAgentPrice.Text); //代理商单价 agentSum = Convert.ToDecimal(txtAgentSum.Text); //代理商额度 agentCommission = Convert.ToDecimal(txtAgentCommission.Text); //代理商提成 citySalePrice = Convert.ToDecimal(txtCitySalePrice.Text); //跨区域单价 citySaleSum = Convert.ToDecimal(txtCitySaleSum.Text); //跨区域销售额 citySaleCommission = Convert.ToDecimal(txtCitySaleCommission.Text); //跨区域提成 if (deliverPrice < salePrice + commissionPrice + agentPrice + citySalePrice) { MessageBox.Show("销售单价、提成单价、代理商单价、跨区销售单价之和不能大于发货单价"); return; } if (cmbUserName.Visible == true && cmbUserName.SelectedIndex == -1 && Convert.ToInt32(txtPercent.Text) != 0) { //如果跨区销售下拉框为可见 且未选择 且 分成不为0 MessageBox.Show("请选择跨区域销售"); return; } string isPaid, hasTax; object ret; if (cbTax.Checked == true) { hasTax = "含税"; } else { hasTax = "不含税"; } if (cbIsPaid.Checked == true) { isPaid = "已付款"; } else { isPaid = "未付款"; } ret = new T_ExpenseAllocationTableAdapter().MyInsert("", SalerId, txtTableNo.Text, Convert.ToInt64(txtCustomerName.Tag), txtProjectName.Text, Convert.ToInt64(txtProductName.Tag), txtType.Text, Amount, deliverPrice, Math.Round(deliverSum, 2), salePrice, Math.Round(SaleSum, 2), Math.Round(DepartSum, 2), Math.Round(saleWages, 2), commissionPrice, Math.Round(commissionSum, 2), Math.Round(saleCommission, 2), agentPrice, Math.Round(agentSum, 2), Math.Round(agentCommission, 2), isPaid, null, "已提交等待商务审核", null, null, null, null, null, null, null, null, null, Convert.ToInt64(mRow.Cells["idDataGridViewTextBoxColumn"].Value), type, Convert.ToInt64(cmbUserName.SelectedValue), Convert.ToDecimal(txtCitySum.Text == "" ? "0" : txtCitySum.Text), Convert.ToDecimal(txtCityWages.Text == "" ? "0" : txtCityWages.Text), hasTax, Math.Round(citySalePrice, 2), Math.Round(citySaleSum, 2), Math.Round(citySaleCommission, 2)); if ((long)ret > 0) { ret = new T_SaleDetailsTableAdapter().UpdateExById(ret.ToString(), Convert.ToInt64(mRow.Cells["idDataGridViewTextBoxColumn"].Value)); MessageBox.Show("已提交"); btnApply.Enabled = false; } else { MessageBox.Show("提交失败"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } this.DialogResult = System.Windows.Forms.DialogResult.OK; }
public string oldType; //原订单类型 private void Form1_Load(object sender, EventArgs e) { DataTable mTable1 = new T_ExpenseAllocationTableAdapter().GetDataById(ExId); var mDataRow = (销售管理.DAL.DataSetExpenseAllocation.T_ExpenseAllocationRow)mTable1.Rows[0]; //cmbMonth.SelectedItem = mDataRow.Month; //txtTableNo.Text = mDataRow.TableNo; //txtCustomerName.Text = mDataRow.CustomerName; txtProjectName.Text = mDataRow.ProjectName; var mProductTable = new T_ProductsTableAdapter().GetDataByID(mDataRow.ProductName); if (mProductTable.Rows.Count > 0) { txtProductName.Text = mProductTable[0].Name; } var mCustomerTable = new T_CustomersTableAdapter().GetDataById(Convert.ToInt64(mDataRow.CustomerName)); if (mProductTable.Rows.Count > 0) { txtCustomerName.Text = mCustomerTable[0].CompanyName; } txtProductName.Tag = mDataRow.ProductName; txtCustomerName.Tag = mDataRow.CustomerName; txtType.Text = mDataRow.ProductType; txtAmount.Text = mDataRow.Amount.ToString(); txtDeliverPrice.Text = mDataRow.DeliverPrice.ToString(); txtDeliverSum.Text = mDataRow.DeliverSum.ToString(); txtSalePrice.Text = mDataRow.SalePrice.ToString(); txtSaleSum.Text = mDataRow.SaleSum.ToString(); txtSaleWages.Text = mDataRow.SaleWages.ToString(); txtCommissionPrice.Text = mDataRow.CommissionPrice.ToString(); txtCommissionSum.Text = mDataRow.CommissionSum.ToString(); txtSaleCommission.Text = mDataRow.SaleComission.ToString(); txtAgentPrice.Text = mDataRow.AgentPrice.ToString(); txtAgentSum.Text = mDataRow.AgentSum.ToString(); txtAgentCommission.Text = mDataRow.AgentCommission.ToString(); SalerId = mDataRow.UserName; DataTable mTable = new T_UsersTableAdapter().GetDataById(SalerId); if (mTable.Rows.Count > 0) { var mDataRow1 = (销售管理.DAL.DataSetUsers.T_UsersRow)mTable.Rows[0]; txtUserName.Text = mDataRow1.UserName; } if (mDataRow.type == "个人订单") { rbPersonal.Checked = true; } else if (mDataRow.type == "部门订单") { rbDepart.Checked = true; } else if (mDataRow.type == "公司跟单") { rbCompany.Checked = true; } else { rbCity.Checked = true; } if (mDataRow.IsCitySalerNull() == false) { if (mDataRow.CitySaler != "0") { cmbUserName.SelectedValue = Convert.ToInt64(mDataRow.CitySaler); } } oldType = mDataRow.type; FailTableNo = mDataRow.TableNo; txtTableNo.Text = mDataRow.TableNo; if (mDataRow.IsPaid == "已付款") { cbIsPaid.Checked = true; } else { cbIsPaid.Checked = false; } if (mDataRow.IsPaidDateNull() == false) { dtpPaidDate.Value = mDataRow.PaidDate; } txtStatus.Text = mDataRow.Status; //+"。" + mDataRow.BusinessRemark; labStatus.Visible = true; txtStatus.Visible = true; btnApply.Enabled = true; if (mDataRow.Status.Contains("不通过") == true && isModify == true) { btnApply.Enabled = true; btnApply.Text = "重新申请"; } else { btnApply.Enabled = true; } //groupBox1.Enabled = false; }