示例#1
0
 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();
     }
 }
示例#2
0
 /*รายงานใบขาย*/
 private void พมพใบขายToolStripMenuItem_Click(object sender, EventArgs e)
 {
     String strSaleHeadId = rowSelect().Cells[1].Value.ToString();
     String sub = strSaleHeadId.Substring(0, 2);
     if (sub == "SC" || sub == "SO")
     {
         if (dataGridView1.SelectedRows.Count == 0 && dataGridView4.SelectedRows.Count == 0) { return; }
         SalePosNew.SalePosReport rpt = new SalePosNew.SalePosReport(DataTrans(), 21, "");
         rpt.ShowDialog();
     }
     else
     {
         Sale.rptShowSaleSelect rptShowSaleSelect = new KTCERP.Sale.rptShowSaleSelect();
         rptShowSaleSelect.StartPosition = FormStartPosition.CenterScreen;   // กำหนด frm ย่อย ให้อยู่ตรงกลาง
         rptShowSaleSelect.setSaleId = Convert.ToInt32(strSaleHeadId);
         rptShowSaleSelect.ShowDialog();
     }
 }
 private void toolStripButton3_Click(object sender, EventArgs e)
 {
     if (dataGridView1.Rows.Count == 0) { return; }
     SalePosNew.SalePosReport rpt = new SalePosNew.SalePosReport(DataSaleReport(), 41, "");
     rpt.ShowDialog();
 }
示例#4
0
        /*บันทึกใบกำกับภาษีในฐานข้อมูล*/
        private void InsertSaleVat()
        {
            String rdate = Class.Function.GetDate(dateTimePicker3.Value);
            String UserName = clsCash.sUserIdLogin;
            if (MessageBox.Show("คุณต้องการบันทึกใบกำกับภาษี " + label53.Text  + "\nใช่หรือไม่ ?", "คำยืนยัน", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                String sqlUpSale = "DELETE SALE_STORE_VAT WHERE SaleVatId='" + label53.Text + "'";
                SqlDataReader readerUpdateHead1 = DBConnString.clsDB.QueryDataReader(sqlUpSale);

                sqlUpSale = "INSERT INTO SALE_STORE_VAT VALUES('" + label53.Text + "','" + rdate + "',GETDATE(),'" + textBox11.Text + "'," +
                    "'1','" + UserName + "')";
                readerUpdateHead1 = DBConnString.clsDB.QueryDataReader(sqlUpSale);
                if (MessageBox.Show("บันทึกสำเร็จ คุณต้องการพิมพ์รายงาน " + label53.Text + "\nใช่หรือไม่ ?", "คำยืนยัน", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    if (dataGridView1.Rows.Count == 0) { return; }
                    SalePosNew.SalePosReport rpt = new SalePosNew.SalePosReport(DataTrans(), 22, "");
                    rpt.ShowDialog();
                }
                setFirstLoad();
                setNewFrom();
            }
        }
示例#5
0
        private void insertDateSale(String strDrow)
        {
            String sql = "";
            List<String> ListSql = new List<String>();
            List<String> ListSqlQtyX = new List<String>();
            String arraydetailid = "";
            if (dataGridView1.Rows.Count > 0)
            {
                arraydetailid += dataGridView1.Rows[0].Cells[0].Value.ToString();
                for (int i = 1; i < dataGridView1.Rows.Count; i++) { arraydetailid += "," + dataGridView1.Rows[i].Cells[0].Value.ToString(); }
            }
            if (arraydetailid == "") { arraydetailid = "0"; }
            if (DBConnString.clsDB.ExecuteTransaction(ListSqlQtyX.ToArray()))
            {
                List<String> ListSqlstsX = new List<String>();
                DBConnString.clsDB.ExecuteTransaction(ListSqlstsX.ToArray());
            }
            if (head != null)
            {
                sql = "SELECT COUNT(DeHeadId) AS CountId FROM DEC_STORE_HEAD WHERE DeHeadId = '" + head + "' ";
                DataTable dtc = Class.DBConnString.clsDB.QueryDataTable(sql);
                Int32 Count = Convert.ToInt32(dtc.Rows[0][0].ToString());
                if (Count > 0)
                {
                    sql = "DELETE DEC_STORE_WEIGHT WHERE DeHeadId = '" + head + "' ";
                    ListSql.Add(sql);
                    sql = "DELETE DEC_STORE_DETAIL WHERE DeHeadId = '" + head + "' ";
                    ListSql.Add(sql);
                    sql = "DELETE DEC_STORE_HEAD WHERE DeHeadId = '" + head + "' ";
                    ListSql.Add(sql);
                }
                //Delete payment
                sql = "select count(PaymentId) from PAYMENT where SaleHeadId = '" + head + "'";
                dtc = Class.DBConnString.clsDB.QueryDataTable(sql);
                Count = Convert.ToInt32(dtc.Rows[0][0].ToString());
                if (Count > 0)
                {
                    sql = "DELETE PAYMENT WHERE SaleHeadId = '" + head + "' ";
                    ListSql.Add(sql);
                }
                //End delete payment
                //Delete paycheck
                sql = "select count(PayCheckId) from PAYCHECK where SaleHeadId = '" + head + "'";
                dtc = Class.DBConnString.clsDB.QueryDataTable(sql);
                Count = Convert.ToInt32(dtc.Rows[0][0].ToString());
                if (Count > 0)
                {
                    sql = "DELETE PAYCHECK WHERE SaleHeadId = '" + head + "' ";
                    ListSql.Add(sql);
                }
                //End delete paycheck
            }

            String strCustomer = Class.Function.GetTextId(textBox13.Text);
            String strTime = DateTime.Now.ToString("hh:mm:ss.fff", System.Globalization.DateTimeFormatInfo.InvariantInfo);
            String strDay = dateTimePicker1.Value.Day.ToString();
            String strMonth = dateTimePicker1.Value.Month.ToString();
            String strYear = dateTimePicker1.Value.Year.ToString();
            String rdate = strYear + "-" + strMonth + "-" + strDay + " " + strTime;
            //String rdate = Class.Function.GetDate(dateTimePicker1.Value);
            Double SaleVat = Convert.ToDouble(textBox20.Text);
            Double SaleShipping = Convert.ToDouble(textBox18.Text);
            Double Discount = Convert.ToDouble(textBox5.Text);
            Double Cash = Convert.ToDouble(textBox8.Text);
            String UserName = clsCash.sUserIdLogin;
            Double Credit = Convert.ToDouble(textBox23.Text);
            Double Exrate1 = Convert.ToDouble(textBox14.Text);
            Double Exrate2 = Convert.ToDouble(textBox21.Text);
            Double TotalPrice = Convert.ToDouble(textBox4.Text);
            Double Vatbase = Convert.ToDouble(textBox6.Text);
            Double DisBath = Convert.ToDouble(textBox19.Text);
            Double Mcash = Convert.ToDouble(textBox22.Text);
            Double TranfMny = Convert.ToDouble(textBox37.Text);
            Double Cheque = Convert.ToDouble(textBox38.Text);
            Double DisCash = Convert.ToDouble(textBox25.Text);
            Double Pay = Convert.ToDouble(label34.Text);
            Double Deposit_Pay = Convert.ToDouble(textBox24.Text);

            getNewDetailId();
            sql = "INSERT INTO DEC_STORE_HEAD(" +
                "DeHeadId,DeHeadDate,DeHeadDatetime,DeHeadDrowId,CustomerId," +
                "DeHeadStatus,DeVat,DeShipping,Discount,Cash," +
                "FeederId,DrowId,LoadingId,FinalDestinationId,Remark," +
                "UserName,ConfirmId,Credit,DeCurrencyId1,DeCurrencyId2," +
                "Exrate1,Exrate2,TotalPrice,VatBase,tax_auto_id," +
                "Disper,DisBath,Mcash,TranfMny,Cheque," +
                "Discash,Pay,Deposit_Pay,Noinv,Detype,DeTypeId" +
                ")VALUES(" +
                "'" + textBox1.Text + "','" + rdate + "',GETDATE(),'" + strDrow + "','" + strCustomer + "'," +
                "'1'," + SaleVat + "," + SaleShipping + "," + Discount + "," + Cash + "," +
                "'" + comboBox8.SelectedValue + "','" + textBox3.Text + "','" + comboBox7.SelectedValue + "','" + comboBox2.SelectedValue + "','" + textBox15.Text + "'," +
                "'" + UserName + "','1'," + Credit + ",'" + comboBox5.SelectedValue + "','" + comboBox4.SelectedValue + "'," +
                "" + Exrate1 + "," + Exrate2 + "," + TotalPrice + "," + Vatbase + ",'" + comboBox3.SelectedValue + "'," +
                "'" + textBox17.Text + "'," + DisBath + "," + Mcash + "," + TranfMny + "," + Cheque + "," +
                "" + DisCash + "," + Pay + "," + Deposit_Pay + ",'" + textBox9.Text + "','1','" + comboBox1.SelectedValue + "'" +
                ")";
            ListSql.Add(sql);
            //Insert Payment
            if (Convert.ToDouble(textBox37.Text) > 0)
            {
                foreach (DataGridViewRow row in dataGridView7.Rows)
                {
                    try
                    {
                        String strBankBookCode = row.Cells[0].Value.ToString();
                        String strPay = row.Cells[5].Value.ToString();
                        sql = "INSERT INTO PAYMENT(SaleHeadId,BankBookCode,Pay)VALUES('" + textBox1.Text + "','" + strBankBookCode + "','" + strPay + "')";
                        ListSql.Add(sql);
                    }
                    catch { MessageBox.Show("error กรุณาป้อนข้อมูลให้ครบถ้วน PAYMENT"); return; }
                }
            }
            //End insert payment
            //Insert PayCheck
            if (Convert.ToDouble(textBox38.Text) > 0)
            {
                foreach (DataGridViewRow row in dataGridView8.Rows)
                {
                    try
                    {
                        String strPayCheckDate = row.Cells[3].Value.ToString();
                        DateTime date1 = DateTime.Parse(strPayCheckDate);
                        strDay = date1.Day.ToString();
                        strMonth = date1.Month.ToString();
                        strYear = (Convert.ToInt16(date1.Year.ToString())).ToString();
                        String strDate = strYear + "-" + strMonth + "-" + strDay;
                        String strBankAccountId = row.Cells[0].Value.ToString();
                        String strBankBranch = row.Cells[2].Value.ToString();
                        String strCheckId = row.Cells[4].Value.ToString();
                        String strPay = row.Cells[5].Value.ToString();
                        sql = "INSERT INTO PAYCHECK(PayCheckDate,SaleHeadId,BankAccountId,BankBranch,CheckId,Pay)VALUES(" +
                            "'" + strDate + "','" + textBox1.Text + "','" + strBankAccountId + "','" + strBankBranch + "'," +
                            "'" + strCheckId + "','" + strPay + "')";
                        ListSql.Add(sql);
                    }
                    catch { MessageBox.Show("error กรุณาป้อนข้อมูลให้ครบถ้วน PAYCHECK"); return; }
                }
            }
            //End insert PayCheck
            //Remove row in table where diffrence is zero
            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                String ProductId = row.Cells[0].Value.ToString();
                String sqlSelect = "SELECT SaleDetailPriceUnit FROM SALE_STORE_DETAIL " +
                    "WHERE SaleHeadId='" + textBox3.Text + "' " +
                    "AND ProductId='" + ProductId + "'";
                DataTable dtPricDiff = Class.DBConnString.clsDB.QueryDataTable(sqlSelect);
                Double strPriceDiff = Convert.ToDouble(dtPricDiff.Rows[0][0].ToString());

                if (Convert.ToDouble(row.Cells[8].Value.ToString()) == strPriceDiff)
                {
                    dataGridView1.Rows.Remove(row);
                }
            }
            //End remove row
            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                try
                {
                    String ProductId = row.Cells[0].Value.ToString();
                    Double SaleDetailQuantityPack = Convert.ToDouble(row.Cells[3].Value.ToString());
                    Double SaleDetailQuantity = Convert.ToDouble(row.Cells[5].Value.ToString());
                    Double SaleDetailWeight = Convert.ToDouble(row.Cells[7].Value.ToString());
                    Double SaleDetailPriceUnit = Convert.ToDouble(row.Cells[8].Value.ToString());
                    Double PriceQuantity = Convert.ToDouble(row.Cells[9].Value.ToString());
                    String Distext = row.Cells[10].Value.ToString();
                    Double Disperunit = Convert.ToDouble(row.Cells[11].Value.ToString());
                    Double Distotal = Convert.ToDouble(row.Cells[12].Value.ToString());
                    Double SaleDetailTotal = Convert.ToDouble(row.Cells[15].Value.ToString());
                    String SdateId = row.Cells[16].Value.ToString();
                    String data = row.Cells[17].Value.ToString();
                    String type = row.Cells[18].Value.ToString();
                    String ProductBorderId = row.Cells[19].Value.ToString();

                    sql = "INSERT INTO DEC_STORE_DETAIL(" +
                        "DeDetailId,DeHeadId,ProductId,DeDetailQuantityPack,DeDetailQuantity," +
                        "DeDetailWeight,DeDetailPriceUnit,PriceQuantity,Distext,DisperUnit," +
                        "Distotal,DeDetailTotal,SdateId,detailType,ProductBorderId)VALUES(" +
                        "" + NewDetailId + ",'" + textBox1.Text + "','" + ProductId + "'," + SaleDetailQuantityPack + "," + SaleDetailQuantity + "," +
                        "" + SaleDetailWeight + "," + SaleDetailPriceUnit + "," + PriceQuantity + ",'" + Distext + "'," + Disperunit + "," +
                        "" + Distotal + "," + SaleDetailTotal + ",'" + SdateId + "','" + type + "','" + ProductBorderId + "')";
                    ListSql.Add(sql);

                    if (type != "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 % ((type == "1") ? 3 : 2) == 0)
                            {
                                String Pack = weight[i];
                                String Quantity = weight[i + 1];
                                String Weight = "0";
                                if (((type == "1") ? 3 : 2) == 3)
                                {
                                    Weight = weight[i + 2];
                                }
                                sql = "INSERT INTO DEC_STORE_WEIGHT(DeDetailId,PackId,DePack,DeWeight,DeHeadId)VALUES(" +
                                    "" + NewDetailId + ",'" + Pack + "'," + Quantity + "," + Weight + ",'" + textBox1.Text + "')";
                                ListSql.Add(sql);
                            }
                        }
                    }
                    NewDetailId = NewDetailId + 1;
                }
                catch { MessageBox.Show("error กรุณาป้อนข้อมูลให้ครบถ้วน INVOICE_ORIGINAL_DETAIL"); return; }
            }

            if (MessageBox.Show("คุณต้องการบันทึกข้อมูลขายต่างประเทศใหม่เลขที่ " + textBox1.Text + "\nใช่หรือไม่ ?", "คำยืนยัน", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {

                if (DBConnString.clsDB.ExecuteTransaction(ListSql.ToArray()))
                {
                    List<String> ListSqlQty = new List<String>();
                    if (DBConnString.clsDB.ExecuteTransaction(ListSqlQty.ToArray()))
                    {
                        List<String> ListSqlsts = new List<String>();
                        if (DBConnString.clsDB.ExecuteTransaction(ListSqlsts.ToArray()))
                        {
                        }
                    }
                }
                //MessageBox.Show("บันทึกข้อมูล " + textBox1.Text + " สำเร็จ");
                if (MessageBox.Show("บันทึกสำเร็จ คุณต้องการพิมพ์รายงาน " + textBox1.Text + "\nใช่หรือไม่ ?", "คำยืนยัน", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    SalePosNew.SalePosReport rpt = new SalePosNew.SalePosReport(DataSaleReportInter(), 34, "");
                    rpt.ShowDialog();
                }
                setFirstLoad();
                setNewForm();
                //else if (CheckFrom == 1) { this.Close(); }
            }
        }
示例#6
0
        /*บันทึกข้อมูลลดหนี้ลงในฐานข้อมูล*/
        private void insertDateSale()
        {
            String sql = "";
            List<String> ListSql = new List<String>();

            if (head != null)
            {
                sql = "SELECT COUNT(DeHeadId) AS CountId FROM deC_STORE_HEAD WHERE deHeadId = '" + head + "' ";
                if (Class.DBConnString.clsDB.QueryExecuteScalarNonAlert(sql).ToInt() > 0)
                {
                    sql = "DELETE deC_STORE_DETAIL WHERE deHeadId = '" + head + "' ";
                    ListSql.Add(sql);
                    sql = "DELETE deC_STORE_HEAD WHERE deHeadId = '" + head + "' ";
                    ListSql.Add(sql);
                }
                //Delete payment
                sql = "select count(PaymentId) from PAYMENT where SaleHeadId = '" + head + "'";
                if (Class.DBConnString.clsDB.QueryExecuteScalarNonAlert(sql).ToInt() > 0)
                {
                    sql = "DELETE PAYMENT WHERE SaleHeadId = '" + head + "' ";
                    ListSql.Add(sql);
                }
                //End delete payment
                //Delete paycheck
                sql = "select count(PayCheckId) from PAYCHECK where SaleHeadId = '" + head + "'";
                if (Class.DBConnString.clsDB.QueryExecuteScalarNonAlert(sql).ToInt() > 0)
                {
                    sql = "DELETE PAYCHECK WHERE SaleHeadId = '" + head + "' ";
                    ListSql.Add(sql);
                }
                //End delete paycheck
            }

            String strCustomer = Class.Function.GetTextId(textBox13.Text);
            String rdate = Class.Function.GetDate(dateTimePicker1.Value);
            Double SaleVat = Convert.ToDouble(textBox20.Text);
            Double Cash = Convert.ToDouble(textBox8.Text);
            String UserName = clsCash.sUserIdLogin;
            Double Credit = Convert.ToDouble(textBox23.Text);
            Double TotalPrice = Convert.ToDouble(textBox2.Text);
            Double Vatbase = Convert.ToDouble(textBox6.Text);
            Double Mcash = Convert.ToDouble(textBox22.Text);
            Double TranfMny = Convert.ToDouble(textBox37.Text);
            Double Cheque = Convert.ToDouble(textBox38.Text);
            Double DisCash = Convert.ToDouble(textBox25.Text);
            Double Pay = Convert.ToDouble(label34.Text);
            Double Deposit_Pay = Convert.ToDouble(textBox24.Text);

            sql = "INSERT INTO deC_STORE_HEAD(" +
                "deHeadId,deHeadDate,deHeadDatetime,CustomerId," +
                "deHeadStatus,deVat,Cash," +
                "SaleHeadId,Remark," +
                "UserName,ConfirmId,Credit," +
                "TotalPrice,VatBase,tax_auto_id," +
                "Mcash,TranfMny,Cheque," +
                "Discash,Pay,Deposit_Pay,ReTypeId,Exrate1) VALUES(" +
                "'" + textBox1.Text + "','" + rdate + "',GETDATE()," + strCustomer + "," +
                "1," + SaleVat + "," + Cash + "," +
                "'" + textBox3.Text + "','" + textBox15.Text + "'," +
                "'" + UserName + "',1," + Credit + "," +
                "" + TotalPrice + "," + Vatbase + "," + comboBox3.SelectedValue + "," +
                "" + Mcash + "," + TranfMny + "," + Cheque + "," +
                "" + DisCash + "," + Pay + "," + Deposit_Pay + "," + comboBox1.SelectedValue + "," + txtRate.Text + ")";
            ListSql.Add(sql);
            //Insert Payment
            if (Convert.ToDouble(textBox37.Text) > 0)
            {
                foreach (DataGridViewRow row in dataGridView7.Rows)
                {
                    try
                    {
                        String strBankBookCode = row.Cells[0].Value.ToString();
                        String strPay = row.Cells[5].Value.ToString();
                        sql = "INSERT INTO PAYMENT(SaleHeadId,BankBookCode,Pay)VALUES('" + textBox1.Text + "','" + strBankBookCode + "','" + strPay + "')";
                        ListSql.Add(sql);
                    }
                    catch { MessageBox.Show("error กรุณาป้อนข้อมูลให้ครบถ้วน"); return; }
                }
            }
            //End insert payment
            //Insert PayCheck
            if (Convert.ToDouble(textBox38.Text) > 0)
            {
                foreach (DataGridViewRow row in dataGridView8.Rows)
                {
                    try
                    {
                        String strDate = Class.Function.GetDate(Convert.ToDateTime(row.Cells[3].Value));
                        String strBankAccountId = row.Cells[0].Value.ToString();
                        String strBankBranch = row.Cells[2].Value.ToString();
                        String strCheckId = row.Cells[4].Value.ToString();
                        String strPay = row.Cells[5].Value.ToString();
                        sql = "INSERT INTO PAYCHECK(PayCheckDate,SaleHeadId,BankAccountId,BankBranch,CheckId,Pay)VALUES(" +
                            "'" + strDate + "','" + textBox1.Text + "','" + strBankAccountId + "','" + strBankBranch + "'," +
                            "'" + strCheckId + "','" + strPay + "')";
                        ListSql.Add(sql);
                    }
                    catch { MessageBox.Show("error กรุณาป้อนข้อมูลให้ครบถ้วน"); return; }
                }
            }

            int id = Class.Function.ReturnId("deDetailId", "deC_STORE_DETAIL");
            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                try
                {
                    String ProductId = row.Cells["proid"].Value.ToString();
                    Double priceold = Convert.ToDouble(row.Cells["priceold"].Value.ToString());
                    Double pricenew = Convert.ToDouble(row.Cells["pricenew"].Value.ToString());
                    Double diff = Convert.ToDouble(row.Cells["diff"].Value.ToString());
                    Double total = Convert.ToDouble(row.Cells["total"].Value.ToString());
                    String did = row.Cells["id"].Value.ToString();

                    sql = "INSERT INTO deC_STORE_DETAIL(" +
                        "deDetailId,deHeadId,ProductId,deDetailPriceUnit,deDetailPriceUnitNew," +
                        "deDetailDiff,deDetailTotal,SaleDetailId) VALUES(" +
                        "" + id + ",'" + textBox1.Text + "','" + ProductId + "'," + priceold + "," + pricenew + "," +
                        "" + diff + "," + total + ",'"+did+"')";
                    ListSql.Add(sql);

                    id++;
                }
                catch { MessageBox.Show("error กรุณาป้อนข้อมูลให้ครบถ้วน"); return; }
            }

            if (MessageBox.Show("คุณต้องการบันทึกข้อมูลลดหนี้ใหม่เลขที่ " + textBox1.Text + "\nใช่หรือไม่ ?", "คำยืนยัน", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {

                if (DBConnString.clsDB.ExecuteTransaction(ListSql.ToArray()))
                {
                    if (MessageBox.Show("บันทึกสำเร็จ คุณต้องการพิมพ์รายงาน " + textBox1.Text + "\nใช่หรือไม่ ?", "คำยืนยัน", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        SalePosNew.SalePosReport rpt = new SalePosNew.SalePosReport(DataSaleReport(textBox1.Text), 36, "");
                        rpt.ShowDialog();
                    }
                }
                setFirstLoad();
                setNewForm();
            }
        }
示例#7
0
 private void s51พมพใบรบคนสนคาToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (dataGridView1.Rows.Count == 0) { return; }
     SalePosNew.SalePosReport rpt = new SalePosNew.SalePosReport(DataSaleReport(), 31, "");
     rpt.ShowDialog();
 }
示例#8
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (dataGridView1.Rows.Count == 0) { MessageBox.Show("ผิดพลาด ไม่มีข้อมูล"); return; }
            if (dataGridView1.Rows.Count != dataGridView2.Rows.Count)
            {
                MetroMessageBox.Show(this, "ข้อมูลไม่เท่ากัน", "คำเตือน", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            String sql = "";
            List<string> sqlList = new List<string>();
            if (head != null) {
                sql = "delete from TRANF_STORE_HEAD where tsHeadId = '"+head+"'";
                sqlList.Add(sql);
                sql = "delete from TRANF_STORE_DETAIL where tsHeadId = '" + head + "'";
                sqlList.Add(sql);
            }

            sql = "insert into TRANF_STORE_HEAD(tsHeadId,tsDate,tsDatetime,DrowId,UserName,Description,Confirm,StatusId) " +
            "values('" + textBox1.Text + "','" + Class.Function .GetDate (dateTimePicker1.Value)  + "',getdate(),'" + textBox2.Text+ "','"+Class.DBConnString.UserName+"','"+textBox5.Text+"','1','1')";
            sqlList.Add(sql);

            int count = dataGridView1.Rows.Count;
            for (int i = 0; i < count; i++) {
                DataGridViewRow d1 = dataGridView1.Rows[i];
                DataGridViewRow d2 = dataGridView2.Rows[i];
                sql = "insert into TRANF_STORE_DETAIL(tsHeadId,ProductId1,productId2,Pack1,Pack2,Quantity1,Quantity2,PriceUnit1,PriceUnit2) " +
                "values('" + textBox1.Text + "','" + d1.Cells["productid"].Value.ToString() + "','" + d2.Cells["productid"].Value.ToString() + "', "+
                "" + d1.Cells["qtypack"].Value.ToString() + "," + d2.Cells["qtypack"].Value.ToString() + "," + d1.Cells["qty"].Value.ToString() + ", "+
                "" + d2.Cells["qty"].Value.ToString() + "," + d1.Cells["priceunit"].Value.ToString() + "," + d2.Cells["priceunit"].Value.ToString() + ")";
                sqlList.Add(sql);
            }

            if (Class.DBConnString.clsDB.ExecuteTransaction(sqlList.ToArray())) {
                if(MetroMessageBox.Show(this,"บันทึกสำเร็จ ต้องการพิมพ์ใบโอนเลขที่ " + textBox1.Text + " ใช่หรือไม่? ","ยืนยัน",MessageBoxButtons.YesNo,MessageBoxIcon.Question )==DialogResult.Yes){
                    SalePosNew.SalePosReport rpt = new SalePosNew.SalePosReport(DataSaleReport(), 41, "");
                    rpt.ShowDialog();
                }
                dataGridView1.Columns.Clear();
                dataGridView2.Columns.Clear();
                textBox2.Text = "";
                textBox5.Text = "";
                textBox1.Text = saleSOid();
            }
        }
示例#9
0
 private void ใบลดหนตางประเทศToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (dataGridView1.Rows.Count == 0) { return; }
     if (InvId == "") { return; }
     SalePosNew.SalePosReport rpt = new SalePosNew.SalePosReport(DataSaleReportInter(), 34, "");
     rpt.ShowDialog();
 }
示例#10
0
 private void ภาษาไทยToolStripMenuItem_Click(object sender, EventArgs e)
 {
     thenSelect(dataGridView1);
     SalePosNew.SalePosReport rpt = new SalePosNew.SalePosReport(DataSaleReport(), 33, "");
     rpt.ShowDialog();
 }
示例#11
0
        /*บันทึกข้อมูลรับคืนสินค้าลงในฐานข้อมูล*/
        private void insertDateSale()
        {
            String sql = "";
            List<String> ListSql = new List<String>();
            List<String> ListSqlQtyX = new List<String>();
            String arraydetailid = "";
            if (dataGridView1.Rows.Count > 0)
            {
                arraydetailid += dataGridView1.Rows[0].Cells["proid"].Value.ToString();
                for (int i = 1; i < dataGridView1.Rows.Count; i++) { arraydetailid += "," + dataGridView1.Rows[i].Cells["proid"].Value.ToString(); }
            }
            if (arraydetailid == "") { arraydetailid = "0"; }
            if (DBConnString.clsDB.ExecuteTransaction(ListSqlQtyX.ToArray()))
            {
                List<String> ListSqlstsX = new List<String>();
                DBConnString.clsDB.ExecuteTransaction(ListSqlstsX.ToArray());
            }
            if (head != null)
            {
                sql = "SELECT COUNT(ReHeadId) AS CountId FROM RE_STORE_HEAD WHERE ReHeadId = '" + head + "' ";
                DataTable dtc = Class.DBConnString.clsDB.QueryDataTable(sql);
                Int32 Count = Convert.ToInt32(dtc.Rows[0][0].ToString());
                if (Count > 0)
                {
                    sql = "DELETE RE_STORE_WEIGHT WHERE ReHeadId = '" + head + "' ";
                    ListSql.Add(sql);
                    sql = "DELETE RE_STORE_DETAIL WHERE ReHeadId = '" + head + "' ";
                    ListSql.Add(sql);
                    sql = "DELETE RE_STORE_HEAD WHERE ReHeadId = '" + head + "' ";
                    ListSql.Add(sql);
                    sql = "DELETE RECEIVE_SHIP WHERE ReceiveHeadId = '" + head + "' and shipType = '" + shipType + "' ";
                    ListSql.Add(sql);
                }
                //Delete payment
                sql = "select count(PaymentId) from PAYMENT where SaleHeadId = '" + head + "'";
                dtc = Class.DBConnString.clsDB.QueryDataTable(sql);
                Count = Convert.ToInt32(dtc.Rows[0][0].ToString());
                if (Count > 0)
                {
                    sql = "DELETE PAYMENT WHERE SaleHeadId = '" + head + "' ";
                    ListSql.Add(sql);
                }
                //End delete payment
                //Delete paycheck
                sql = "select count(PayCheckId) from PAYCHECK where SaleHeadId = '" + head + "'";
                dtc = Class.DBConnString.clsDB.QueryDataTable(sql);
                Count = Convert.ToInt32(dtc.Rows[0][0].ToString());
                if (Count > 0)
                {
                    sql = "DELETE PAYCHECK WHERE SaleHeadId = '" + head + "' ";
                    ListSql.Add(sql);
                }
                //End delete paycheck
            }

            String strCustomer = Class.Function.GetTextId(textBox13.Text);
            String strTime = DateTime.Now.ToString("hh:mm:ss.fff", System.Globalization.DateTimeFormatInfo.InvariantInfo);
            String strDay = dateTimePicker1.Value.Day.ToString();
            String strMonth = dateTimePicker1.Value.Month.ToString();
            String strYear = dateTimePicker1.Value.Year.ToString();
            String rdate = strYear + "-" + strMonth + "-" + strDay + " " + strTime;
            //String rdate = Class.Function.GetDate(dateTimePicker1.Value);
            Double SaleVat = Convert.ToDouble(textBox20.Text);
            Double SaleShipping = Convert.ToDouble(textBox18.Text);
            Double Discount = Convert.ToDouble(textBox5.Text);
            Double Cash = Convert.ToDouble(textBox8.Text);
            String UserName = clsCash.sUserIdLogin;
            Double Credit = Convert.ToDouble(textBox23.Text);
            //Double Exrate1 = Convert.ToDouble(textBox14.Text);
            //Double Exrate2 = Convert.ToDouble(textBox21.Text);
            Double TotalPrice = Convert.ToDouble(textBox4.Text);
            Double Vatbase = Convert.ToDouble(textBox6.Text);
            Double DisBath = Convert.ToDouble(textBox19.Text);
            Double Mcash = Convert.ToDouble(textBox22.Text);
            Double TranfMny = Convert.ToDouble(textBox37.Text);
            Double Cheque = Convert.ToDouble(textBox38.Text);
            Double DisCash = Convert.ToDouble(textBox25.Text);
            Double Pay = Convert.ToDouble(label34.Text);
            //Double Deposit_Pay = Convert.ToDouble(textBox24.Text);

            getNewDetailId();
            sql = "INSERT INTO RE_STORE_HEAD(" +
                "ReHeadId,ReHeadDate,ReHeadDatetime,ReHeadDrowId,CustomerId," +
                "ReHeadStatus,ReVat,ReShipping,Discount,Cash," +
                "AbountId,Saleheadid,Noinv,ReHeadSaleTypeId,Remark," +
                "UserName,ConfirmId,Credit,ReCurrencyId1,ReCurrencyId2," +
                "Exrate1,Exrate2,TotalPrice,VatBase,tax_auto_id," +
                "Disper,DisBath,Mcash,TranfMny,Cheque," +
                "Discash,Pay,Deposit_Pay,Retype,ReTypeId," +
                "ShipperId,ShipBill,ShipDate)VALUES(" +
                "'" + textBox1.Text + "','" + rdate + "',GETDATE(),'','" + strCustomer + "'," +
                "'1'," + SaleVat + "," + SaleShipping + "," + Discount + "," + Cash + "," +
                "'3','" + textBox3.Text + "','','','" + textBox15.Text + "'," +
                "'" + UserName + "','1'," + Credit + ",'',''," +
                "'1','1'," + TotalPrice + "," + Vatbase + ",'" + comboBox3.SelectedValue + "'," +
                "'" + textBox17.Text + "'," + DisBath + "," + Mcash + "," + TranfMny + "," + Cheque + "," +
                "" + DisCash + "," + Pay + ",0,'1','" + comboBox1.SelectedValue + "'," +
                "'" + Class.Function.GetTextId(txtShip.Text) + "','" + txtShipBill.Text + "','" + Class.Function.GetDate(dtpShipDate.Value) + "')";
            ListSql.Add(sql);
            //Insert Payment
            if (Convert.ToDouble(textBox37.Text) > 0)
            {
                foreach (DataGridViewRow row in dataGridView7.Rows)
                {
                    try
                    {
                        String strBankBookCode = row.Cells[0].Value.ToString();
                        String strPay = row.Cells[5].Value.ToString();
                        sql = "INSERT INTO PAYMENT(SaleHeadId,BankBookCode,Pay)VALUES('" + textBox1.Text + "','" + strBankBookCode + "','" + strPay + "')";
                        ListSql.Add(sql);
                    }
                    catch { MessageBox.Show("error กรุณาป้อนข้อมูลให้ครบถ้วน"); return; }
                }
            }
            //End insert payment
            //Insert PayCheck
            if (Convert.ToDouble(textBox38.Text) > 0)
            {
                foreach (DataGridViewRow row in dataGridView8.Rows)
                {
                    try
                    {
                        String strPayCheckDate = row.Cells[3].Value.ToString();
                        DateTime date1 = DateTime.Parse(strPayCheckDate);
                        strDay = date1.Day.ToString();
                        strMonth = date1.Month.ToString();
                        strYear = (Convert.ToInt16(date1.Year.ToString())).ToString();
                        String strDate = strYear + "-" + strMonth + "-" + strDay;
                        String strBankAccountId = row.Cells[0].Value.ToString();
                        String strBankBranch = row.Cells[2].Value.ToString();
                        String strCheckId = row.Cells[4].Value.ToString();
                        String strPay = row.Cells[5].Value.ToString();
                        sql = "INSERT INTO PAYCHECK(PayCheckDate,SaleHeadId,BankAccountId,BankBranch,CheckId,Pay)VALUES(" +
                            "'" + strDate + "','" + textBox1.Text + "','" + strBankAccountId + "','" + strBankBranch + "'," +
                            "'" + strCheckId + "','" + strPay + "')";
                        ListSql.Add(sql);
                    }
                    catch { MessageBox.Show("error กรุณาป้อนข้อมูลให้ครบถ้วน"); return; }
                }
            }
            //End insert PayCheck
            //Insert ship
            if (dgvship.Rows.Count > 0)
            {
                foreach (DataGridViewRow row in dgvship.Rows)
                {
                    String shipnum = Convert.ToDouble(row.Cells[0].Value.ToString()).ToString();
                    String shipproduct = row.Cells[1].Value.ToString();
                    String shipunit = Convert.ToDouble(row.Cells[3].Value.ToString()).ToString();
                    String shipsum = Convert.ToDouble(row.Cells[4].Value.ToString()).ToString();
                    String strunit = row.Cells[2].Value.ToString();
                    sql = "INSERT INTO RECEIVE_SHIP(Shipnum,ShipProduct,ShipUnit,ShipSum,ReceiveHeadId,unit,shipType)" +
                      "VALUES (" + shipnum + ",'" + shipproduct + "'," + shipunit + "," + shipsum + ",'" + textBox1.Text + "','" + strunit + "','" + shipType + "')";
                    ListSql.Add(sql);
                }
            }
            //End insert ship

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                try
                {
                    String ProductId = row.Cells["proid"].Value.ToString();
                    Double SaleDetailQuantityPack = Convert.ToDouble(row.Cells["qtyp"].Value.ToString());
                    Double SaleDetailQuantity = Convert.ToDouble(row.Cells["qty"].Value.ToString());
                    Double SaleDetailWeight = Convert.ToDouble(row.Cells["w"].Value.ToString());
                    Double SaleDetailPriceUnit = Convert.ToDouble(row.Cells["ppu"].Value.ToString());
                    Double PriceQuantity = Convert.ToDouble(row.Cells["p"].Value.ToString());
                    String Distext = row.Cells["dp"].Value.ToString();
                    Double Disperunit = Convert.ToDouble(row.Cells["du"].Value.ToString());
                    Double Distotal = Convert.ToDouble(row.Cells["d"].Value.ToString());
                    Double SaleDetailTotal = Convert.ToDouble(row.Cells["ps"].Value.ToString());
                    String SdateId = row.Cells["sid"].Value.ToString();
                    String data = row.Cells["dt"].Value.ToString();
                    String type = row.Cells["t"].Value.ToString();

                    //sql = "UPDATE [RE_STORE_DETAIL] SET [QtySaleRe]='" + SaleDetailQuantity + "' WHERE ProductId='" + ProductId + "' AND  ";
                    //ListSql.Add(sql);

                    sql = "INSERT INTO RE_STORE_DETAIL(" +
                        "ReDetailId,ReHeadId,ProductId,ReDetailQuantityPack,ReDetailQuantity," +
                        "ReDetailWeight,ReDetailPriceUnit,PriceQuantity,Distext,DisperUnit," +
                        "Distotal,ReDetailTotal,SdateId,detailType)VALUES(" +
                        "" + NewDetailId + ",'" + textBox1.Text + "','" + ProductId + "'," + SaleDetailQuantityPack + "," + SaleDetailQuantity + "," +
                        "" + SaleDetailWeight + "," + SaleDetailPriceUnit + "," + PriceQuantity + ",'" + Distext + "'," + Disperunit + "," +
                        "" + Distotal + "," + SaleDetailTotal + ",'" + SdateId + "','" + type + "')";
                    ListSql.Add(sql);

                    if (type != "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 % ((type == "1") ? 3 : 2) == 0)
                            {
                                String Pack = weight[i];
                                String Quantity = weight[i + 1];
                                String Weight = "0";
                                if (((type == "1") ? 3 : 2) == 3)
                                {
                                    Weight = weight[i + 2];
                                }
                                sql = "INSERT INTO RE_STORE_WEIGHT(ReDetailId,PackId,RePack,ReWeight,ReHeadId)VALUES(" +
                                    "" + NewDetailId + "," + Pack + "," + Quantity + "," + Weight + ",'" + textBox1.Text + "')";
                                ListSql.Add(sql);
                            }
                        }
                    }
                    NewDetailId = NewDetailId + 1;
                }
                catch { MessageBox.Show("error กรุณาป้อนข้อมูลให้ครบถ้วน"); return; }
            }

            if (MessageBox.Show("คุณต้องการบันทึกข้อมูลขายใหม่เลขที่ " + textBox1.Text + "\nใช่หรือไม่ ?", "คำยืนยัน", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {

                if (DBConnString.clsDB.ExecuteTransaction(ListSql.ToArray()))
                {
                    List<String> ListSqlQty = new List<String>();
                    if (DBConnString.clsDB.ExecuteTransaction(ListSqlQty.ToArray()))
                    {
                        List<String> ListSqlsts = new List<String>();
                        if (DBConnString.clsDB.ExecuteTransaction(ListSqlsts.ToArray()))
                        {
                        }
                    }
                }
                //MessageBox.Show("บันทึกข้อมูล " + textBox1.Text + " สำเร็จ");
                if (MessageBox.Show("บันทึกสำเร็จ คุณต้องการพิมพ์รายงาน " + textBox1.Text + "\nใช่หรือไม่ ?", "คำยืนยัน", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    SalePosNew.SalePosReport rpt = new SalePosNew.SalePosReport(DataSaleReport(), 31, "");
                    rpt.ShowDialog();

                    //SalePosNew.SalePosReport rpt = new SalePosNew.SalePosReport(DataSaleReport(), 32, "");
                    //rpt.ShowDialog();

                }
                setFirstLoad();
                setNewForm();
                //else if (CheckFrom == 1) { this.Close(); }
            }
        }