private void button1_Click(object sender, EventArgs e) { if (radioButton1.Checked) { SalePosNew.frmCallReport rpt = new SalePosNew.frmCallReport(Slip(), 11); rpt.ShowDialog(); } else if (radioButton2.Checked) { SalePosNew.SalePosReport rpt = new SalePosNew.SalePosReport(DataTrans(), 21, ""); rpt.ShowDialog(); } else { Requisition.rptSaleApp rpt = new Requisition.rptSaleApp(); rpt.StartPosition = FormStartPosition.CenterScreen; String i = "select top 1 d.sdateid from sale_store_detail d where d.saleheadid = '" + strHeadId + "'"; String x = "select saleappheadid from sale_app_head where sdateid = '" + Class.DBConnString.clsDB.QueryExecuteScalar(i) + "'"; rpt.setSaleAppHeadId = Convert.ToInt32(Class.DBConnString.clsDB.QueryExecuteScalar(x)); rpt.ShowDialog(); } }
private void PrintReport(String _SaleAppHeadId) { if (MessageBox.Show("คุณต้องการพิมพ์ใบเบิก " + ((dataGridView1.CurrentRow.Cells[1].Value.ToString() != "-") ? dataGridView1.CurrentRow.Cells[1].Value.ToString() : _SaleAppHeadId), "ยืนยันการพิมพ์", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == System.Windows.Forms.DialogResult.OK) { Requisition.rptSaleApp rpt = new Requisition.rptSaleApp(); rpt.StartPosition = FormStartPosition.CenterScreen; rpt.setSaleAppHeadId = Convert.ToInt32(_SaleAppHeadId); rpt.ShowDialog(); } }
private void PrintReport(String _SaleAppHeadId) { if (MessageBox.Show("คุณต้องการพิมพ์ใบเบิก " + _SaleAppHeadId, "ยืนยันการพิมพ์", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == System.Windows.Forms.DialogResult.OK) { Requisition.rptSaleApp rpt = new Requisition.rptSaleApp(); rpt.StartPosition = FormStartPosition.CenterScreen; String i = "select saleappheadid from sale_app_Head where sdateid = '" + _SaleAppHeadId + "'"; rpt.setSaleAppHeadId = Convert.ToInt32(Class.DBConnString.clsDB.QueryExecuteScalar(i)); rpt.ShowDialog(); } }
private void insertAndUpdate() { String sql = ""; List<String> ListSql = new List<String>(); String rid = txtRec.Text; String idHead = HEADID; if (idHead == "") { idHead = getSaleAppHeadId(); } if (txtRec.Enabled == false) { if (rid != saleId() && rid != saleId(1)) { DialogResult dialogResult = MessageBox.Show("รหัส " + rid + " ถูกใช้แล้ว หากกด YES ระบบจะบันทึกและสร้างรหัสอัตโนมัติ หากกด NO ระบบจะยังไม่บันทึก แต่จะเรียกรหัสใหม่อีกครั้ง", "แจ้งเตือน", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { if (checkBox1.Checked == true) { rid = saleId(1); } else { rid = saleId(); } } else if (dialogResult == DialogResult.No) { if (checkBox1.Checked == true) { rid = saleId(1); } else { rid = saleId(); } return; } } } if (txtRec.Enabled == true) { sql = "select Sdateid,StatusId,saleappheadid from sale_app_head where Sdateid = '" + rid + "'"; DataTable dt = Class.DBConnString.clsDB.QueryDataTable(sql); if (dt.Rows.Count < 1) { sql = "select saleappheadid,StatusId,saleappheadid from sale_app_head where saleappheadid = '" + rid + "'"; dt = Class.DBConnString.clsDB.QueryDataTable(sql); } if (dt.Rows[0][0].ToString() != "" && dt.Rows[0][1].ToString() == "2") { sql = "DELETE FROM Sale_App_Weight WHERE saleappheadid = '" + dt.Rows[0][2].ToString() + "' "; ListSql.Add(sql); sql = "DELETE FROM Sale_App_Detail WHERE saleappheadid = '" + dt.Rows[0][2].ToString() + "' "; ListSql.Add(sql); sql = "DELETE FROM Sale_App_Head WHERE saleappheadid = '" + dt.Rows[0][2].ToString() + "' "; ListSql.Add(sql); } else { MessageBox.Show("ใบเบิกนี้ ไม่สามรถทำการแก้ไขได้"); return; } } String cusid = Class.Function.GetTextId(textBox4.Text); String rdate = Class.Function.GetDate(dptRecDate.Value); String round = textBox3.Text + textBox2.Text; String number = textBox1.Text; String UserName = Class.clsCash.sUserIdLogin; String Description = TxtDescription.Text; if (rid.Substring(0, 1) != "R") { sql = "INSERT INTO Sale_App_HEAD(SdateId,SaleAppHeadId,SaleAppHeadDate,SaleAppHeadDateSave,CustomerId,IsSend,UserName,SaleHeadId,AbountId,RequisitionId,statusId,Descript) " + "VALUES(NULL,'" + idHead + "','" + rdate + "',GETDATE()," + cusid + ",'0','" + UserName + "',NULL,'" + round + "','" + number + "',2,'" + Description + "')"; ListSql.Add(sql); } else { sql = "INSERT INTO Sale_App_HEAD(SdateId,SaleAppHeadId,SaleAppHeadDate,SaleAppHeadDateSave,CustomerId,IsSend,UserName,SaleHeadId,AbountId,RequisitionId,statusId,Descript) " + "VALUES('" + rid + "','" + idHead + "','" + rdate + "',GETDATE()," + cusid + ",'0','" + UserName + "',NULL,'" + round + "','" + number + "',2,'" + Description + "')"; ListSql.Add(sql); } foreach (DataGridViewRow row in dgvReceive.Rows) { String ProductId = row.Cells[0].Value.ToString(); String QuantityPack = Convert.ToDouble(row.Cells[2].Value.ToString()).ToString(); String QuantitySale = Convert.ToDouble(row.Cells[4].Value.ToString()).ToString(); String QuantityWeight = Convert.ToDouble(row.Cells[6].Value.ToString()).ToString(); String Note = row.Cells[10].Value.ToString(); String data = row.Cells[9].Value.ToString(); String type = row.Cells[8].Value.ToString(); String typeTemp = row.Cells[8].Value.ToString(); if (txtRec.Enabled == true) { type = ((SDATEID != "") ? row.Cells[8].Value.ToString() + "" : (Convert.ToInt16(row.Cells[8].Value.ToString()) - 1).ToString()) + ""; } sql = "INSERT INTO Sale_App_Detail(SaleAppHeadId,ProductId,ProductAppType,SaleAppDetailQuantityPack,SaleAppDetailQuantity,SaleAppDetailWeight,Note) " + "VALUES ('" + idHead + "','" + ProductId + "'," + type + "," + QuantityPack + "," + QuantitySale + "," + QuantityWeight + ",'" + Note + "')"; ListSql.Add(sql); if (typeTemp != "3") { String[] weight = data.Split('#'); for (int i = 0; i < weight.Length - 1; i++)//1 2 3,4 5 6,7 8 9 { if (i % ((typeTemp == "1") ? 3 : 2) == 0) { String Pack = weight[i]; String Quantity = weight[i + 1]; String Weight = "0"; if (((typeTemp == "1") ? 3 : 2) == 3) { Weight = weight[i + 2]; } sql = "INSERT INTO Sale_App_Weight(SaleAppHeadId,ProductId,SaleAppPackId,SaleAppPack,SaleAppWeight) " + "VALUES ('" + idHead + "','" + ProductId + "'," + Pack + "," + Quantity + "," + Weight + ")"; ListSql.Add(sql); } } } } if (MessageBox.Show("คุณต้องการบันทึกข้อมูลใบเบิกขายใหม่เลขที่ " + ((rid==null)?idHead:rid) + "\nใช่หรือไม่ ?", "คำยืนยัน", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (Class.DBConnString.clsDB.ExecuteTransaction(ListSql.ToArray())) { if (MessageBox.Show("บันทึกสำเร็จ คุณต้องการพิมพ์รายงาน " + ((rid == null) ? idHead : rid) + "\nใช่หรือไม่ ?", "คำยืนยัน", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Requisition.rptSaleApp rpt = new Requisition.rptSaleApp(); rpt.StartPosition = FormStartPosition.CenterScreen; rpt.setSaleAppHeadId = Convert.ToInt32(idHead); rpt.ShowDialog(); } retuenNulltext(); this.DialogResult = DialogResult.OK; } } }