Ejemplo n.º 1
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (txtContractor.Text == "") { MessageBox.Show("กรุณาเลือกผู้รับงาน"); return; }
     String strDate = "วันที่ดำเนินงาน " + dtpBegin.Text + " ถึง " + dtpEnd.Text + "";
     GetReport rpt = new GetReport(DataSent(), 3,strDate);
     rpt.ShowDialog();
 }
Ejemplo n.º 2
0
        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            if (dgvHead.Rows.Count > 0)
            {
                GetReport rpt = new GetReport(DataSent(), 1);
                rpt.ShowDialog();
            }

            //GetReport rpt = new GetReport(DataSentTest(), 2);
            //rpt.ShowDialog();
        }
Ejemplo n.º 3
0
        /*บันทึกข้อมูลของใบโอนสินค้าส่งไปฝากขายลงในฐานข้อมูล*/
        private void InsertValue()
        {
            String sql = "";
            List<String> ListSql = new List<String>();

            sql = "USE KTC select count(ReqId) from REQUIREMENT_HEAD where ReqId = '" + txtReqId.Text + "'";
            DataTable dtc = Class.DBConnString.clsDB.QueryDataTable(sql);
            Int32 Count = Convert.ToInt32(dtc.Rows[0][0].ToString());
            if (Count != 0)
            {
                sql = "USE KTC DELETE REQUIREMENT_DETAIL WHERE ReqId = '" + txtReqId.Text + "' ";
                ListSql.Add(sql);
                sql = "USE KTC DELETE REQUIREMENT_HEAD WHERE ReqId = '" + txtReqId.Text + "' ";
                ListSql.Add(sql);
            }

            String DateBegin = Class.Function.GetDate(dtpBegin.Value);
            String DateEnd = Class.Function.GetDate(dtpEnd.Value);
            String Manager = Class.Function.GetTextId(txtManager.Text);
            //String Contractor = Class.Function.GetTextId(txtContractor.Text);

            sql = "USE KTC INSERT INTO REQUIREMENT_HEAD(ReqId,DurationDay,DurationMonth,DateBegin,DateEnd,Manager,Title," +
                "ApproveId,DateSave,ReqHeadStatusId)" +
                "VALUES('" + txtReqId.Text + "','" + txtDurationDay.Text + "','" + txtDurationMonth.Text + "','" + DateBegin + "'," +
                "'" + DateEnd + "','" + Manager + "','" + txtTitle.Text + "','1',GETDATE(),'1')";
            ListSql.Add(sql);

            foreach (DataGridViewRow row in dgvPart.Rows)
            {
                try
                {

                    String strPartialId = row.Cells[0].Value.ToString();
                    String PartDesc = row.Cells[1].Value.ToString();
                    String PartialDurationDay = row.Cells["durationday"].Value.ToString();
                    String PartialDurationMonth = row.Cells["durationmonth"].Value.ToString();
                    String Contractor = Class.Function.GetTextId(row.Cells["ผู้รับงาน"].Value.ToString());
                    String Note = row.Cells["หมายเหตุ"].Value.ToString();
                    String PartDateEnd = Class.Function.GetDate(Convert.ToDateTime(row.Cells["กำหนดส่งงาน"].Value));
                    String PartDateBegin = Class.Function.GetDate(Convert.ToDateTime(row.Cells["วันที่เริ่มงานระบบย่อย"].Value));
                    String ApproveId = row.Cells["ApprovedId"].Value.ToString();
                    String RequestStatusId = row.Cells["RequestStatusId"].Value.ToString();

                    sql = "USE KTC INSERT INTO REQUIREMENT_DETAIL(PartialId,ReqId,PartialDesc,PartialDurationDay,PartialDurationMonth,Note,Contractor,PartDateEnd,ApproveId,PartDateBegin,RequestStatusId)" +
                        "VALUES ('" + strPartialId + "','" + txtReqId.Text + "','" + PartDesc + "','" + PartialDurationDay + "','" + PartialDurationMonth + "','" + Note + "'," +
                        "'" + Contractor + "','" + PartDateEnd + "','" + ApproveId + "','" + PartDateBegin + "','" + RequestStatusId + "')";
                    ListSql.Add(sql);
                }
                catch { MessageBox.Show("error กรุณาป้อนข้อมูลให้ครบถ้วน"); return; }
            }

            if (MessageBox.Show("คุณต้องการบันทึกข้อมูลใบสั่งงานใหม่เลขที่ " + txtReqId.Text + "\nใช่หรือไม่ ?", "คำยืนยัน", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                if (DBConnString.clsDB.ExecuteTransaction(ListSql.ToArray()))
                {
                    if (MessageBox.Show("บันทึกสำเร็จ คุณต้องการพิมพ์รายงาน " + txtReqId.Text + "\nใช่หรือไม่ ?", "คำยืนยัน", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        GetReport rpt = new GetReport(DataSent(txtReqId.Text), 1);
                        rpt.ShowDialog();
                    }
                }
                ClearFrom();
            }
        }