private void btnEdit_Click(object sender, EventArgs e) { BaseData.Items items = new BaseData.Items(); DataTable ItemDT = items.SelectItemByItemID(txtItemID.Text); if (ItemDT.Rows.Count > 0) { //dgvApplyProducts.SelectedRows[0].Cells["ItemID"].Value = txtItemID.Text; //dgvApplyProducts.SelectedRows[0].Cells["Detail"].Value = txtDetail.Text; //dgvApplyProducts.SelectedRows[0].Cells["Price"].Value = txtPrice.Value; //dgvApplyProducts.SelectedRows[0].Cells["MoneyUnit"].Value = txtMoneyUnit.SelectedIndex + 1; //dgvApplyProducts.SelectedRows[0].Cells["Count"].Value = txtCount.Value; //dgvApplyProducts.SelectedRows[0].Cells["SelforGift"].Value = txtSelforGift.SelectedIndex + 1; //dgvApplyProducts.SelectedRows[0].Cells["ApprovalCount"].Value = txtApprovalCount.Value; //dgvApplyProducts.SelectedRows[0].Cells["ApprovalDiscount"].Value = txtApprovalDiscount.Value; //dgvApplyProducts.SelectedRows[0].Cells["FinalPrice"].Value = txtFinalPrice.Value; //dgvApplyProducts.SelectedRows[0].Cells["Recipient"].Value = txtRecipient.Text; //dgvApplyProducts.SelectedRows[0].Cells["Relationship"].Value = txtRelationship.Text; //dgvApplyProducts.SelectedRows[0].Cells["Reason"].Value = txtReason.Text; foreach (DataRow dr in AddApplicationDT.Rows) { if (dr.RowState != DataRowState.Deleted && dr["CodeID"].ToString() == dgvApplyProducts.SelectedRows[0].Cells["dgvCodeID"].Value.ToString()) { dr["ItemID"] = txtItemID.Text; dr["Detail"] = txtDetail.Text; dr["Price"] = txtPrice.Value; dr["MoneyUnit"] = txtMoneyUnit.SelectedIndex + 1; dr["Count"] = txtCount.Value; dr["SelforGift"] = txtSelforGift.SelectedIndex + 1; dr["ApprovalCount"] = txtApprovalCount.Value; dr["ApprovalDiscount"] = txtApprovalDiscount.Value; dr["FinalPrice"] = txtFinalPrice.Value; dr["Recipient"] = txtRecipient.Text; dr["Relationship"] = txtRelationship.Text; dr["Reason"] = txtReason.Text; dr["PhoneNum"] = txtPhoneNum.Text; } } } else { MessageBox.Show("不存在该货号"); } GetTotalPrice(); }
//添加 private void btnAdd_Click(object sender, EventArgs e) { if (!ExcitItemID) { MessageBox.Show("The SKU does not Excit ", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { BaseData.Items items = new BaseData.Items(); DataTable ItemDT = items.SelectItemByItemID(txtItemID.Text); if (ItemDT.Rows.Count > 0) { DataRow dr = AddApplicationDT.NewRow(); codeID++; dr["CodeID"] = codeID.ToString(); dr["ItemID"] = txtItemID.Text; dr["Detail"] = txtDetail.Text; dr["Price"] = txtPrice.Value; dr["Count"] = txtCount.Value; dr["MoneyUnit"] = txtMoneyUnit.SelectedIndex + 1; dr["SelforGift"] = txtSelforGift.SelectedIndex + 1; dr["ApprovalCount"] = txtApprovalCount.Value; dr["ApprovalDiscount"] = txtApprovalDiscount.Value; dr["FinalPrice"] = txtFinalPrice.Value; dr["Recipient"] = txtRecipient.Text; dr["Relationship"] = txtRelationship.Text; dr["Reason"] = txtReason.Text; dr["IsSuccess"] = 0; dr["IsDelete"] = 0; AddApplicationDT.Rows.Add(dr); } } GetTotalPrice(); }
private void btnAdd_Click(object sender, EventArgs e) { //if (!Regex.IsMatch(txtCount4.Text, "^[0-9]*$") || txtCount4.Text == "") //{ // MessageBox.Show("请输入数字"); //} //else if (txtItemID.Text == "") { MessageBox.Show("请填写货号"); } else { BaseData.Items items = new BaseData.Items(); DataTable ItemDT = items.SelectItemByItemID(txtItemID.Text); if (ItemDT.Rows.Count > 0) { bool Repeated = false; foreach (DataRow dr in AddApplicationDT.Rows) { if (dr.RowState == DataRowState.Deleted) { dr.Delete(); } else { if (dr["ItemID"].ToString() == txtItemID.Text && dr["ItemHighlight"].ToString() == "1") { dr["App_Count"] = (int)dr["App_Count"] + (int)numCount.Value; Repeated = true; } if (dr["ItemID2"].ToString() == txtItemID.Text && dr["ItemHighlight"].ToString() == "2") { dr["App_Count"] = (int)dr["App_Count"] + (int)numCount.Value; Repeated = true; } } } if (!Repeated) { DataRow dr = AddApplicationDT.NewRow(); dr["CtrlID"] = txtCtrlID.Text; dr["Department"] = txtDepartment4.Text; dr["App_Level"] = txtLevel4.Text; dr["ItemID"] = ItemDT.Rows[0]["ItemID"]; dr["ItemID2"] = ItemDT.Rows[0]["ItemID2"]; dr["Detail"] = ItemDT.Rows[0]["Detail"]; dr["Price"] = ItemDT.Rows[0]["Price"]; dr["App_Count"] = int.Parse(this.numCount.Value.ToString()); dr["IsDelete"] = 0; if (dr["ItemID"].ToString() == txtItemID.Text) { dr["ItemHighlight"] = 1; } else if (dr["ItemID2"].ToString() == txtItemID.Text) { dr["ItemHighlight"] = 2; } AddApplicationDT.Rows.Add(dr); HighlightItemID(); } txtItemID.Text = ""; txtItemID.Focus(); } else { MessageBox.Show("货号错误"); txtItemID.Text = ""; txtItemID.Focus(); } } }
//添加 private void btnAdd_Click(object sender, EventArgs e) { decimal GiftTotal = 0; //if (txtMoneyUnit.SelectedIndex == 2) GiftTotal = EmailControl.config.HKD; //else if (txtMoneyUnit.SelectedIndex == 1) GiftTotal = EmailControl.config.USD; //else GiftTotal = EmailControl.config.CNY; switch (txtMoneyUnit.SelectedIndex) { case 0: GiftTotal = EmailControl.config.CNY; break; case 1: GiftTotal = EmailControl.config.USD; break; case 2: GiftTotal = EmailControl.config.HKD; break; case 3: GiftTotal = EmailControl.config.MOP; break; case 4: GiftTotal = EmailControl.config.SGD; break; case 5: GiftTotal = EmailControl.config.MYR; break; case 6: GiftTotal = EmailControl.config.GBP; break; case 7: GiftTotal = EmailControl.config.EUR; break; case 8: GiftTotal = EmailControl.config.JPY; break; case 9: GiftTotal = EmailControl.config.TWD; break; } if (!ExcitItemID) { MessageBox.Show("不存在该货号", "消息", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (AddApplicationDT.Rows.Count > 4) { MessageBox.Show("超过五项,无法添加", "消息", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (txtSelforGift.SelectedIndex == 1 && txtPrice.Value * txtCount.Value > GiftTotal && (txtReason.Text == "" || txtRecipient.Text == "" || txtRelationship.Text == "" || txtPhoneNum.Text == "")) { MessageBox.Show("请填写赠礼明细", "消息", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { BaseData.Items items = new BaseData.Items(); DataTable ItemDT = items.SelectItemByItemID(txtItemID.Text); if (ItemDT.Rows.Count > 0) { DataRow dr = AddApplicationDT.NewRow(); codeID++; //dr["CodeID"] = codeID.ToString(); dr["ItemID"] = txtItemID.Text; dr["Detail"] = txtDetail.Text; dr["Price"] = txtPrice.Value; dr["Count"] = txtCount.Value; dr["MoneyUnit"] = txtMoneyUnit.SelectedIndex + 1; dr["SelforGift"] = txtSelforGift.SelectedIndex + 1; dr["ApprovalCount"] = txtCount.Value; dr["ApprovalDiscount"] = txtApprovalDiscount.Value; dr["FinalPrice"] = txtFinalPrice.Value; dr["Recipient"] = txtRecipient.Text; dr["Relationship"] = txtRelationship.Text; dr["Reason"] = txtReason.Text; dr["PhoneNum"] = txtPhoneNum.Text; dr["IsSpecial"] = txtIsSpecial.Text; dr["IsSuccess"] = 0; dr["IsDelete"] = 0; AddApplicationDT.Rows.Add(dr); } } for (int i = 0; i < AddApplicationDT.Rows.Count; i++) { AddApplicationDT.Rows[i]["CodeID"] = i + 1; } GetTotalPrice(); txtItemID.Text = ""; txtDetail.Text = ""; txtPrice.Value = 0; txtCount.Value = 1; txtFinalPrice.Value = 0; txtItemID.Focus(); txtMoneyUnit.SelectedIndex = 0; }