Esempio n. 1
0
        private void btnNext6_Click(object sender, EventArgs e)
        {
            string lvUnit = GsysSQL.fncFindItemUnit(txtID.Text);

            lbDate.Text       = txtDate.DateTime.ToString("dd/MM/yyyy");
            lbItem.Text       = GsysSQL.fncFindItemName(txtID.Text);
            lbAmount.Text     = txtAmount.Text + " " + lvUnit;
            lbUserResive.Text = GsysSQL.fncFindFullEmpName(txtUserResive.Text);
            if (pvMode != "IN")
            {
                lbUserPay.Text = GsysSQL.fncFindFullEmpName(txtUserPay.Text);
            }
            else
            {
                lbUserPay.Text = " - ";
            }

            if (txtID.Text == "00021" || txtID.Text == "00022" || txtID.Text == "00023")
            {
                tabControl1.SelectedIndex = 7;
            }
            else
            {
                tabControl1.SelectedIndex = 6;
            }
        }
Esempio n. 2
0
        private void btnNext2_Click(object sender, EventArgs e)
        {
            if (txtID.Text == "")
            {
                MessageBox.Show("กรุณาระบุรหัส", "แจ้งเตือน", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtID.Text = "";
                txtID.Focus();
                return;
            }
            else if (txtName.Text == "")
            {
                MessageBox.Show("กรุณาระบุชื่อ", "แจ้งเตือน", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtName.Text = "";
                txtName.Focus();
                return;
            }
            else
            {
                string lvChk = GsysSQL.fncFindItemName(txtID.Text);
                if (lvChk == "")
                {
                    MessageBox.Show("ไม่พบข้อมูลรหัสนี้  กรุณาตรวจสอบ", "แจ้งเตือน", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtID.Text   = "";
                    txtName.Text = "";
                    txtID.Focus();
                    return;
                }

                tabControl1.SelectedIndex = 2;
                txtAmount.Text            = "";
                txtAmount.Focus();
            }
        }
Esempio n. 3
0
        private void txtID_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                string lvName = GsysSQL.fncFindItemName(txtID.Text);

                if (lvName != "")
                {
                    txtName.Text = lvName;
                    btnNext2.PerformClick();
                }
                else
                {
                    MessageBox.Show("ไม่พบข้อมูล กรุณาตรวจสอบ", "แจ้งเตือน", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtID.Text   = "";
                    txtName.Text = "";
                    txtID.Focus();
                    return;
                }
            }
        }
Esempio n. 4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (pvMode == "IN")
            {
                #region รับเข้า
                //เช็คข้อมูล
                if (txtDate.EditValue == "")
                {
                    MessageBox.Show("กรุณาระบุ วันที่", "แจ้งเตือน", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtDate.Focus();
                    return;
                }
                else if (txtID.Text == "")
                {
                    MessageBox.Show("กรุณาระบุ รหัส", "แจ้งเตือน", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtID.Focus();
                    return;
                }
                else if (Gstr.fncToInt(txtAmount.Text) <= 0)
                {
                    MessageBox.Show("กรุณาระบุ จำนวน", "แจ้งเตือน", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtAmount.Focus();
                    return;
                }
                else if (txtUserResive.Text == "")
                {
                    MessageBox.Show("กรุณาระบุ ผู้รับ", "แจ้งเตือน", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtUserResive.Focus();
                    return;
                }

                string lvType       = "R";
                string lvDate       = Gstr.fncChangeTDate(txtDate.EditValue.ToString());
                string lvItemID     = Gstr.fncGetDataCode(txtID.Text, ";");
                string lvAmount     = txtAmount.Text;
                string lvBal        = GsysSQL.fncFindBal(lvItemID);
                string lvUserResive = txtUserResive.Text;
                string lvUserPay    = "";
                string lvRemark     = txtRemark.Text;

                string lvSQL     = "";
                string lvResault = "";

                int lvTotalBal = Gstr.fncToInt(lvBal) + Gstr.fncToInt(lvAmount);
                if (lvTotalBal < 0)
                {
                    lvTotalBal = 0;
                }

                //Update ยอด
                lvSQL     = "Update SysITEM_Stock set Item_Amount = '" + lvTotalBal + "' Where Item_ID = '" + lvItemID + "' ";
                lvResault = GsysSQL.fncExecuteQueryData(lvSQL);

                //Insert เคลื่อนไหว
                lvSQL     = "Insert into Inv_Moving (M_Type, M_Date, M_ItemID, M_AmountR, M_AmountP, M_AmountBal, M_UserResive, M_UserPay, M_Remark) ";
                lvSQL    += "values('" + lvType + "', '" + lvDate + "', '" + lvItemID + "', '" + lvAmount + "', '', '" + lvTotalBal + "', '" + lvUserResive + "', '" + lvUserPay + "', '" + lvRemark + "')";
                lvResault = GsysSQL.fncExecuteQueryData(lvSQL);

                if (lvResault == "Success")
                {
                    GVar.gvSave = true;
                    MessageBox.Show("บันทึกข้อมูลเรียบร้อย", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                #endregion
            }
            else if (pvMode == "Borrow")
            {
                #region ยืมของ
                //เช็คข้อมูล
                if (txtDate.EditValue == "")
                {
                    MessageBox.Show("กรุณาระบุ วันที่", "แจ้งเตือน", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtDate.Focus();
                    return;
                }
                else if (txtID.Text == "")
                {
                    MessageBox.Show("กรุณาระบุ รหัส", "แจ้งเตือน", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtID.Focus();
                    return;
                }
                else if (Gstr.fncToInt(txtAmount.Text) <= 0)
                {
                    MessageBox.Show("กรุณาระบุ จำนวน", "แจ้งเตือน", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtAmount.Focus();
                    return;
                }
                else if (txtUserResive.Text == "")
                {
                    MessageBox.Show("กรุณาระบุ ผู้ขอเบิก", "แจ้งเตือน", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtUserResive.Focus();
                    return;
                }
                else if (txtUserPay.Text == "")
                {
                    MessageBox.Show("กรุณาระบุ ผู้จ่าย", "แจ้งเตือน", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtUserResive.Focus();
                    return;
                }

                string lvType       = "B";
                string lvDate       = Gstr.fncChangeTDate(txtDate.EditValue.ToString());
                string lvItemID     = Gstr.fncGetDataCode(txtID.Text, ";");
                string lvAmount     = txtAmount.Text;
                string lvBal        = GsysSQL.fncFindBal(lvItemID);
                string lvUserResive = Gstr.fncGetDataCode(txtUserResive.Text, ";");
                string lvUserPay    = Gstr.fncGetDataCode(txtUserPay.Text, ";");
                string lvRemark     = txtRemark.Text;

                string lvSQL     = "";
                string lvResault = "";

                int lvTotalBal = Gstr.fncToInt(lvBal) - Gstr.fncToInt(lvAmount);
                int lvMinStock = Gstr.fncToInt(GsysSQL.fncFindMinStock(lvItemID));

                string lvOption = "";
                if (ChkMouse.Checked)
                {
                    lvOption += "Mouse ";
                }
                if (ChkMousePad.Checked)
                {
                    lvOption += "MousePad ";
                }
                if (ChkAdapter.Checked)
                {
                    lvOption += "Adapter ";
                }
                if (ChkPointer.Checked)
                {
                    lvOption += "Pointer ";
                }
                if (ChkFlashDrive.Checked)
                {
                    lvOption += "FlashDrive ";
                }

                lvOption = lvOption.Replace(' ', ',');

                ////ห้ามจ่ายติดลบ
                //if (lvTotalBal < 0)
                //{
                //    MessageBox.Show("จำนวนคงเหลือไม่เพียงพอ", "แจ้งเตือน", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //    txtAmount.Focus();
                //    return;
                //}

                //if (lvTotalBal < 0) lvTotalBal = 0;

                ////Update ยอด
                //lvSQL = "Update SysITEM_Stock set Item_Amount = '" + lvTotalBal + "' Where Item_ID = '" + lvItemID + "' ";
                //lvResault = GsysSQL.fncExecuteQueryData(lvSQL);

                //Insert เคลื่อนไหว
                lvSQL     = "Insert into Inv_Moving (M_Type, M_Date, M_ItemID, M_AmountR, M_AmountP, M_AmountBal, M_UserResive, M_UserPay, M_Remark, M_Option) ";
                lvSQL    += "values('" + lvType + "', '" + lvDate + "', '" + lvItemID + "', '', '" + lvAmount + "', '" + lvTotalBal + "', '" + lvUserResive + "', '" + lvUserPay + "', '" + lvRemark + "', '" + lvOption + "')";
                lvResault = GsysSQL.fncExecuteQueryData(lvSQL);

                if (lvResault == "Success")
                {
                    GVar.gvSave = true;
                    string lvUserName = GsysSQL.fncFindFullEmpName(lvUserResive);
                    string lvItemName = GsysSQL.fncFindItemName(lvItemID);
                    string lvItemUnit = GsysSQL.fncFindItemUnit(lvItemID);
                    if (lvItemName == "อื่นๆ")
                    {
                        lvItemName = lvRemark;
                    }
                    string lvMessage = "แจ้งเตือน " + lvUserName + " ได้ยืม  " + lvItemName + "  จำนวน " + lvAmount + " " + lvItemUnit + " " + lvRemark;
                    lineNotify(lvMessage);

                    MessageBox.Show("บันทึกข้อมูลเรียบร้อย", "แจ้งเตือน", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                #endregion
            }
            else
            {
                #region เบิกจ่าย
                //เช็คข้อมูล
                if (txtDate.EditValue == "")
                {
                    MessageBox.Show("กรุณาระบุ วันที่", "แจ้งเตือน", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtDate.Focus();
                    return;
                }
                else if (txtID.Text == "")
                {
                    MessageBox.Show("กรุณาระบุ รหัส", "แจ้งเตือน", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtID.Focus();
                    return;
                }
                else if (Gstr.fncToInt(txtAmount.Text) <= 0)
                {
                    MessageBox.Show("กรุณาระบุ จำนวน", "แจ้งเตือน", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtAmount.Focus();
                    return;
                }
                else if (txtUserResive.Text == "")
                {
                    MessageBox.Show("กรุณาระบุ ผู้ขอเบิก", "แจ้งเตือน", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtUserResive.Focus();
                    return;
                }
                else if (txtUserPay.Text == "")
                {
                    MessageBox.Show("กรุณาระบุ ผู้จ่าย", "แจ้งเตือน", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtUserResive.Focus();
                    return;
                }

                string lvType       = "P";
                string lvDate       = Gstr.fncChangeTDate(txtDate.EditValue.ToString());
                string lvItemID     = Gstr.fncGetDataCode(txtID.Text, ";");
                string lvAmount     = txtAmount.Text;
                string lvBal        = GsysSQL.fncFindBal(lvItemID);
                string lvUserResive = Gstr.fncGetDataCode(txtUserResive.Text, ";");
                string lvUserPay    = Gstr.fncGetDataCode(txtUserPay.Text, ";");
                string lvRemark     = txtRemark.Text;

                string lvSQL     = "";
                string lvResault = "";

                int lvTotalBal = Gstr.fncToInt(lvBal) - Gstr.fncToInt(lvAmount);
                int lvMinStock = Gstr.fncToInt(GsysSQL.fncFindMinStock(lvItemID));

                //ห้ามจ่ายติดลบ
                if (lvTotalBal < 0)
                {
                    MessageBox.Show("จำนวนคงเหลือไม่เพียงพอ", "แจ้งเตือน", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtAmount.Focus();
                    return;
                }

                if (lvTotalBal < 0)
                {
                    lvTotalBal = 0;
                }

                //Update ยอด
                lvSQL     = "Update SysITEM_Stock set Item_Amount = '" + lvTotalBal + "' Where Item_ID = '" + lvItemID + "' ";
                lvResault = GsysSQL.fncExecuteQueryData(lvSQL);

                //Insert เคลื่อนไหว
                lvSQL     = "Insert into Inv_Moving (M_Type, M_Date, M_ItemID, M_AmountR, M_AmountP, M_AmountBal, M_UserResive, M_UserPay, M_Remark) ";
                lvSQL    += "values('" + lvType + "', '" + lvDate + "', '" + lvItemID + "', '', '" + lvAmount + "', '" + lvTotalBal + "', '" + lvUserResive + "', '" + lvUserPay + "', '" + lvRemark + "')";
                lvResault = GsysSQL.fncExecuteQueryData(lvSQL);

                if (lvResault == "Success")
                {
                    if (lvTotalBal <= lvMinStock && lvMinStock != 0)
                    {
                        string lvMessage = "แจ้งเตือน " + txtName.Text + " ใกล้หมดแล้ว ยอดคงเหลือปัจุบัน คือ " + lvTotalBal;
                        lineNotify(lvMessage);
                    }
                    else
                    {
                        string lvEmpName  = GsysSQL.fncFindFullEmpName(lvUserResive);
                        string lvItemName = GsysSQL.fncFindItemName(lvItemID);
                        string lvItemUnit = GsysSQL.fncFindItemUnit(lvItemID);

                        string lvMessage = "แจ้งเตือน " + lvEmpName + " ได้เบิก " + lvItemName + " จำนวน " + lvAmount + " " + lvItemUnit;
                        lineNotify(lvMessage);
                    }

                    MessageBox.Show("บันทึกข้อมูลเรียบร้อย", "แจ้งเตือน", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                #endregion
            }
        }
Esempio n. 5
0
        public void lvLoadItem(bool lvShow)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                btnreg.Enabled      = false;
                btnIn.Enabled       = false;
                btnOut.Enabled      = false;
                btnBorrow.Enabled   = false;
                btnNoteBook.Enabled = false;

                string lvSQL = "Select Top 50 * from Inv_Moving Where M_Type in ('R','P') Order by M_Pk Desc ";

                DataTable DT = new DataTable();
                DT = GsysSQL.fncGetQueryData(lvSQL, DT);

                int lvNumRow = DT.Rows.Count;
                sp1.ActiveSheet.RowCount = lvNumRow;

                progressBar1.Maximum = lvNumRow;
                progressBar1.Value   = 0;
                pnStatus.Visible     = true;

                for (int i = 0; i < lvNumRow; i++)
                {
                    sp1.ActiveSheet.Cells[i, 0].Text = Gstr.fncChangeSDate(DT.Rows[i]["M_Date"].ToString());
                    sp1.ActiveSheet.Cells[i, 1].Text = DT.Rows[i]["M_ItemID"].ToString();
                    sp1.ActiveSheet.Cells[i, 2].Text = GsysSQL.fncFindItemName(DT.Rows[i]["M_ItemID"].ToString());
                    sp1.ActiveSheet.Cells[i, 3].Text = DT.Rows[i]["M_AmountR"].ToString();
                    sp1.ActiveSheet.Cells[i, 4].Text = DT.Rows[i]["M_AmountP"].ToString();
                    sp1.ActiveSheet.Cells[i, 5].Text = DT.Rows[i]["M_AmountBal"].ToString();
                    sp1.ActiveSheet.Cells[i, 6].Text = GsysSQL.fncFindEmpName(DT.Rows[i]["M_UserResive"].ToString());
                    sp1.ActiveSheet.Cells[i, 7].Text = GsysSQL.fncFindEmpName(DT.Rows[i]["M_UserPay"].ToString());
                    sp1.ActiveSheet.Cells[i, 8].Text = GsysSQL.fncFindEmpName(DT.Rows[i]["M_Remark"].ToString());

                    progressBar1.Value += 1;
                    Application.DoEvents();
                }

                pnStatus.Visible = false;
                DT.Dispose();

                btnreg.Enabled      = true;
                btnIn.Enabled       = true;
                btnOut.Enabled      = true;
                btnBorrow.Enabled   = true;
                btnNoteBook.Enabled = true;

                if (lvShow)
                {
                    tabControl1.SelectedIndex = 0;
                }

                this.Cursor = Cursors.Default;
            }
            catch
            {
                Application.Restart();
            }
        }
Esempio n. 6
0
        private void FncListViewDragDrop(object sender, DragEventArgs e, ListView lv, string lvAddress)
        {
            //คืนของ
            string lvItemCode = "";

            if (lvAddress == "")
            {
                //หาสิ่งที่เลือก
                string lvItemSelect = "";
                if (e.Data.GetDataPresent(typeof(List <ListViewItem>)))
                {
                    var items = (List <ListViewItem>)e.Data.GetData(typeof(List <ListViewItem>));
                    // move to dest LV
                    foreach (ListViewItem lvi in items)
                    {
                        lvItemSelect = lvi.Text;
                    }
                }

                //ถ้าเป็นช่องเดิมไม่มีการย้ายให้ Return
                bool lvChk = false;
                foreach (ListViewItem item in lv.Items)
                {
                    if (item.Text == lvItemSelect)
                    {
                        lvChk = true;
                        break;
                    }
                }

                if (lvChk)
                {
                    return;
                }

                //ยืนยัน
                string lvTxtAlert = "ตรวจสอบอุปกรณ์ ว่าครบหรือไม่ ";
                //if (GVar.gvDateBill != Gstr.fncChangeTDate(txtDate.Text)) lvTxtAlert = "  **วันที่ไม่ตรงกับใบเสร็จ**"+ Environment.NewLine + Environment.NewLine + "ยืนยันการทำรายการต่อหรือไม่?";
                DialogResult dialogResult = MessageBox.Show(lvTxtAlert, "ยืนยันการคืน NoteBook ?", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.No)
                {
                    return;
                }
                else
                {
                    string lvMsg = "";
                    if (e.Data.GetDataPresent(typeof(List <ListViewItem>)))
                    {
                        var items = (List <ListViewItem>)e.Data.GetData(typeof(List <ListViewItem>));
                        // move to dest LV
                        foreach (ListViewItem lvi in items)
                        {
                            if (lvi.Text == "Dell")
                            {
                                lvMsg      = "แจ้งเตือน NoteBook Dell ได้ถูกนำมาคืนแล้ว";
                                lvItemCode = "00021";
                            }
                            else if (lvi.Text == "ASUS")
                            {
                                lvMsg      = "แจ้งเตือน NoteBook ASUS ได้ถูกนำมาคืนแล้ว";
                                lvItemCode = "00022";
                            }
                            else if (lvi.Text == "ThinkPad")
                            {
                                lvMsg      = "แจ้งเตือน NoteBook ThinkPad ได้ถูกนำมาคืนแล้ว";
                                lvItemCode = "00023";
                            }
                            else if (lvi.Text == "Lenovo")
                            {
                                lvMsg      = "แจ้งเตือน NoteBook Lenovo ได้ถูกนำมาคืนแล้ว";
                                lvItemCode = "00024";
                            }
                        }
                    }

                    //Update ยอด
                    string lvSQL     = "Update Inv_Moving set M_Type = 'T' Where M_ItemID = '" + lvItemCode + "' ";
                    string lvResault = GsysSQL.fncExecuteQueryData(lvSQL);

                    lineNotify(lvMsg);
                }
            }

            if (e.Data.GetDataPresent(typeof(List <ListViewItem>)))
            {
                var items = (List <ListViewItem>)e.Data.GetData(typeof(List <ListViewItem>));
                // move to dest LV
                foreach (ListViewItem lvi in items)
                {
                    if (lvAddress != "")
                    {
                        GVar.gvSave   = false;
                        GVar.gvBorrow = true;
                        frmIN frm = new frmIN();
                        frm.pvMode = "Borrow";
                        lvItemCode = "";

                        if (lvi.Text == "Dell")
                        {
                            lvItemCode = "00021";
                        }
                        else if (lvi.Text == "ASUS")
                        {
                            lvItemCode = "00022";
                        }
                        else if (lvi.Text == "ThinkPad")
                        {
                            lvItemCode = "00023";
                        }
                        else if (lvi.Text == "Lenovo")
                        {
                            lvItemCode = "00024";
                        }

                        frm.txtID.Text     = lvItemCode;
                        frm.txtName.Text   = GsysSQL.fncFindItemName(lvItemCode);
                        frm.txtRemark.Text = "ใช้งาน สำหรับ " + lvAddress;
                        frm.ShowDialog();
                    }

                    if (GVar.gvSave)
                    {
                        // LVI obj can only belong to one LVI, remove
                        lvi.ListView.Items.Remove(lvi);
                        lv.Items.Add(lvi);
                    }
                }
            }

            lvLoadItemBorrow(true);
        }