Esempio n. 1
0
 private void itemInfoAdd()
 {
     #region 判斷
     string msg = "";
     int    n;
     if (string.IsNullOrEmpty(txtAmount.Text))
     {
         msg = "請輸入金額";
     }
     else if (string.IsNullOrEmpty(txtItemInfo.Text))
     {
         msg = "請輸入商品資訊";
     }
     else if (!int.TryParse(txtAmount.Text, out n))
     {
         msg = "金額欄位請輸入數字";
     }
     if (!string.IsNullOrEmpty(msg))
     {
         APConfig.SweetAlert(ShowBoxType.alert, msg);
         return;
     }
     #endregion
     DataGridViewRowCollection rows = dgvItem.Rows;
     rows.Add(new Object[] { ddlType.SelectedItem.ToString(), txtItemInfo.Text, txtAmount.Text });
     loadTotalAmount();
 }
Esempio n. 2
0
        private bool check()
        {
            string msg     = "";
            bool   isEmpty = false;


            if (string.IsNullOrEmpty(txtName.Text))
            {
                msg     = "欄位不能為空值!";
                isEmpty = true;
            }

            if (!isEmpty && !string.IsNullOrEmpty(txtIndex.Text) && txtIndex.Text != "0")
            {
                PhraseInfo view = new PhraseInfo(APConfig.Conn);
                view.Conditions  = " 1=1 ";
                view.Conditions += " AND " + view.getCondition(PhraseInfo.ncConditions.category.ToString(), ddlCategory.SelectedItem.ToString());
                view.Conditions += " AND " + view.getCondition(PhraseInfo.ncConditions.index.ToString(), txtIndex.Text);
                if (view.calculateCount() > 0)
                {
                    msg = "排序已存在!請重新選擇!";
                }
            }

            if (!string.IsNullOrEmpty(msg))
            {
                APConfig.SweetAlert(ShowBoxType.alert, msg);
            }
            return(string.IsNullOrEmpty(msg) ? true : false);
        }
Esempio n. 3
0
 private void loadData(string pserno)
 {
     if (string.IsNullOrEmpty(pserno))
     {
         APConfig.SweetAlert(ShowBoxType.alert, "載入失敗!聯繫Hugo!");
     }
     else
     {
         InventoryInfo view = new InventoryInfo(APConfig.Conn);
         view.Conditions  = " 1=1 ";
         view.Conditions += " AND " + view.getCondition(InventoryInfo.ncConditions.serno.ToString(), pserno);
         if (view.load())
         {
             serno = view.INV_SERNO;
             if (string.IsNullOrEmpty(view.INV_CODE)) //寄庫品
             {
                 txtCode.Text    = view.INV_CODE;
                 txtName.Text    = view.INV_NAME;
                 txtAmount.Text  = view.INV_POSTAMT.ToString();
                 dpkDTTM.Value   = view.INV_POSTDTTM;
                 txtComment.Text = view.INV_POSTCOMMENT;
             }
             else
             {
                 txtCode.Text    = view.INV_CODE;
                 txtName.Text    = view.INV_NAME;
                 txtAmount.Text  = view.INV_INAMT.ToString();
                 dpkDTTM.Value   = view.INV_INDTTM;
                 txtComment.Text = view.INV_INCOMMENT;
             }
         }
     }
 }
Esempio n. 4
0
        private void btnInventoryDelete_Click(object sender, EventArgs e)
        {
            try
            {
                if (dgvInventory.SelectedRows.Count > 0)
                {
                    List <string> sernolist    = new List <string>();
                    string        delSernoList = "";
                    foreach (DataGridViewRow row in dgvInventory.SelectedRows)
                    {
                        sernolist.Add(row.Cells["dgvInventory_Serno"].Value.ToString());
                    }
                    delSernoList = APConfig.sqlArrayFormat(string.Join(",", sernolist));

                    using (var form = new PickInventoryDelete(mode.View, delSernoList))
                    {
                        panelInventory.Visible = false;
                        panelMask.Visible      = true;
                        var result = form.ShowDialog();
                        panelInventory.Visible = true;
                        panelMask.Visible      = false;
                    }
                    inventoryLoadData(ddlInventoryPage.SelectedIndex + 1);
                }
            }
            catch (Exception ex)
            {
                APConfig.SweetAlert(ShowBoxType.alert, string.Format("刪除失敗 {0}", ex.Message));
            }
        }
Esempio n. 5
0
 private void btnPhraseDelete_Click(object sender, EventArgs e)
 {
     try
     {
         if (dgvPhrase.SelectedRows.Count > 0 && APConfig.SweetAlert(ShowBoxType.confirm, string.Format("是否確定要刪除{0}筆?", dgvPhrase.SelectedRows.Count)))
         {
             List <string> sernolist    = new List <string>();
             string        delSernoList = "";
             foreach (DataGridViewRow row in dgvPhrase.SelectedRows)
             {
                 sernolist.Add(string.Format("'{0}'", row.Cells["dgvPhrase_Serno"].Value.ToString()));
             }
             delSernoList = string.Join(",", sernolist);
             Phrase ent         = new Phrase(APConfig.Conn);
             string sConditions = ent.getCondition(Phrase.ncConditions.sernolist.ToString(), delSernoList);
             ent.deleteAll(sConditions);
             phraseLoadData();
             APConfig.SweetAlert(ShowBoxType.alert, "刪除完成");
         }
     }
     catch (Exception ex)
     {
         APConfig.SweetAlert(ShowBoxType.alert, string.Format("刪除失敗 {0}", ex.Message));
     }
 }
Esempio n. 6
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         dgvInventory.EndEdit();
         List <string> sernolist    = new List <string>();
         string        delSernoList = "";
         foreach (DataGridViewRow row in dgvInventory.Rows)
         {
             DataGridViewCheckBoxCell chk = (DataGridViewCheckBoxCell)row.Cells[2];
             if ((bool)chk.Value)
             {
                 sernolist.Add(row.Cells["dgvInventory_Serno"].Value.ToString());
             }
         }
         delSernoList = APConfig.sqlArrayFormat(string.Join(",", sernolist));
         Inventory ent         = new Inventory(APConfig.Conn);
         string    sConditions = ent.getCondition(Inventory.ncConditions.sernolist.ToString(), delSernoList);
         ent.deleteAll(sConditions);
         APConfig.SweetAlert(ShowBoxType.alert, "刪除完成");
         this.Close();
     }
     catch (Exception ex)
     {
         APConfig.SweetAlert(ShowBoxType.alert, string.Format("刪除失敗 {0}", ex.Message));
     }
 }
Esempio n. 7
0
        private bool checkAvg()
        {
            string msg = "";

            if (dgvItem.SelectedRows.Count <= 1)
            {
                msg = "請選取商品資訊至少大於一筆!";
            }
            else if (String.IsNullOrEmpty(txtAvgAmount.Text))
            {
                msg = "平均金額不能為空值!";
            }
            else
            {
                int total = 0;
                int avg   = int.Parse(txtAvgAmount.Text);
                foreach (DataGridViewRow row in dgvItem.SelectedRows)
                {
                    int importAmt = int.Parse(row.Cells["dgvItem_Import"].Value.ToString());
                    total += importAmt;
                    if (importAmt > avg || total > avg)
                    {
                        msg = "平均金額設定需大於選擇進貨金額總和!";
                    }
                }
            }
            if (!string.IsNullOrEmpty(msg))
            {
                APConfig.SweetAlert(ShowBoxType.alert, msg);
            }
            return(string.IsNullOrEmpty(msg) ? true : false);
        }
Esempio n. 8
0
        private bool checkAdd()
        {
            string msg = "";

            if (mode == mode.Add && dgvItem.RowCount <= 0)
            {
                msg = "商品資訊無法為空!";
            }
            else if (mode == mode.Edit && string.IsNullOrEmpty(txtAmount.Text))
            {
                msg = "商品金額無法為空!";
            }
            else if (mode == mode.Edit && string.IsNullOrEmpty(txtName.Text))
            {
                msg = "商品名稱無法為空!";
            }
            else if (mode == mode.Edit && string.IsNullOrEmpty(txtCode.Text))
            {
                msg = "商品代碼無法為空!";
            }


            if (!string.IsNullOrEmpty(msg))
            {
                APConfig.SweetAlert(ShowBoxType.alert, msg);
            }
            return(string.IsNullOrEmpty(msg) ? true : false);
        }
Esempio n. 9
0
 private void login()
 {
     if (checkLogin())
     {
         AccountInfo view = new AccountInfo(APConfig.Conn);
         view.Conditions = view.getCondition(AccountInfo.ncConditions.ACCOUNT.ToString(), txtLoginAccount.Text);
         if (view.load())
         {
             if (view.ACT_PASSWORD != txtLoginPassword.Text)
             {
                 APConfig.SweetAlert(ShowBoxType.alert, "密碼錯誤!");
             }
             else
             {
                 APConfig.AccountName = view.ACT_NAME;
                 APConfig.SweetAlert(ShowBoxType.alert, string.Format("歡迎使用!\r\n{0}", view.ACT_NAME));
                 this.Hide();
                 Main form = new Main();
                 form.ShowDialog();
                 this.Close();
             }
         }
         else
         {
             APConfig.SweetAlert(ShowBoxType.alert, "查無此帳號!");
         }
     }
 }
Esempio n. 10
0
 private void btnClose_Click(object sender, EventArgs e)
 {
     if (APConfig.SweetAlert(ShowBoxType.confirm, "確定要離開嗎?"))
     {
         this.Close();
         Environment.Exit(Environment.ExitCode);
     }
 }
Esempio n. 11
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (mode == mode.Add && checkAdd())
     {
         int count = 0;
         foreach (DataGridViewRow row in dgvItem.Rows)
         {
             Inventory ent = new Inventory(APConfig.Conn);
             ent.INV_SERNO    = row.Cells["dgvItem_Serno"].Value.ToString();
             ent.ModifyFields = string.Format("{0};{1};{2};{3};{4};{5}"
                                              , Inventory.ncFields.INV_STATUS.ToString()
                                              , Inventory.ncFields.INV_RETURNAMT.ToString()
                                              , Inventory.ncFields.INV_RETURNDTTM.ToString()
                                              , Inventory.ncFields.INV_RETURNCOMMENT.ToString()
                                              , Inventory.ncFields.INV_MODIFIEDBY.ToString()
                                              , Inventory.ncFields.INV_MODIFIEDDTTM.ToString());
             ent.INV_STATUS        = InventoryStatus.進貨退出.ToString();
             ent.INV_RETURNAMT     = Convert.ToInt32(row.Cells["dgvItem_Amount"].Value);
             ent.INV_RETURNCOMMENT = row.Cells["dgvItem_Comment"].Value.ToString();
             ent.INV_RETURNDTTM    = DateTime.Parse(row.Cells["dgvItem_ImportDTTM"].Value.ToString());
             ent.INV_MODIFIEDBY    = APConfig.AccountName;
             ent.INV_MODIFIEDDTTM  = DateTime.Now;
             count += ent.update();
         }
         APConfig.SweetAlert(ShowBoxType.alert, string.Format("退貨完成!\r\n新增 {0} 件退貨單", count.ToString()));
         this.DialogResult = DialogResult.OK;
         this.Close();
     }
     else if (mode == mode.Edit && checkAdd())
     {
         Inventory ent = new Inventory(APConfig.Conn);
         ent.INV_SERNO    = serno;
         ent.ModifyFields = string.Format("{0};{1};{2};{3};{4}"
                                          , Inventory.ncFields.INV_RETURNAMT.ToString()
                                          , Inventory.ncFields.INV_RETURNDTTM.ToString()
                                          , Inventory.ncFields.INV_RETURNCOMMENT.ToString()
                                          , Inventory.ncFields.INV_MODIFIEDBY.ToString()
                                          , Inventory.ncFields.INV_MODIFIEDDTTM.ToString());
         ent.INV_RETURNAMT     = Convert.ToInt32(txtReturnAmount.Text);
         ent.INV_RETURNDTTM    = DateTime.Parse(dpkReturnDTTM.Value.ToString());
         ent.INV_RETURNCOMMENT = txtReturnComment.Text;
         ent.INV_MODIFIEDBY    = APConfig.AccountName;
         ent.INV_MODIFIEDDTTM  = DateTime.Now;
         ent.update();
         APConfig.SweetAlert(ShowBoxType.alert, "修改完成");
         this.DialogResult = DialogResult.OK;
         this.Close();
     }
     else if (mode == mode.View)
     {
         this.DialogResult = DialogResult.OK;
         this.Close();
     }
     else
     {
         return;
     }
 }
Esempio n. 12
0
        private bool checkAdd()
        {
            string msg     = "";
            bool   isEmpty = false;
            int    count   = 0;

            string[] condReqName = { "txtMobile", "txtPhone1", "txtPhone2" }; //判斷欄位三個至少填一個
            string[] condName    = { "txtName", "txtAddr", "txtMain" };       //必填欄位

            foreach (Control c in this.Controls)
            {
                if (c is BunifuMetroTextbox)
                {
                    BunifuMetroTextbox textBox = c as BunifuMetroTextbox;
                    if (condName.Contains(textBox.Name) && textBox.Text == string.Empty)
                    {
                        msg     = "欄位不能為空值!";
                        isEmpty = true;
                    }
                    else if (condReqName.Contains(textBox.Name) && textBox.Text == string.Empty)
                    {
                        count++;
                    }
                }
                else if (c is BunifuDropdown)
                {
                    BunifuDropdown dropdown = c as BunifuDropdown;
                    if (dropdown.selectedIndex == -1)
                    {
                        msg     = "欄位不能為空值!";
                        isEmpty = true;
                    }
                }
            }

            if (count == condReqName.Length)
            {
                msg     = "電話欄位至少輸入一欄!";
                isEmpty = true;
            }

            if (!isEmpty && mode == mode.Add)
            {
                RosterInfo vRoster = new RosterInfo(APConfig.Conn);
                vRoster.Conditions = vRoster.getCondition(RosterInfo.ncConditions.main.ToString(), txtMain.Text);
                if (vRoster.calculateCount() > 0)
                {
                    msg = "該手機號碼已經有資料!請重複確認!";
                }
            }

            if (!string.IsNullOrEmpty(msg))
            {
                APConfig.SweetAlert(ShowBoxType.alert, msg);
            }
            return(string.IsNullOrEmpty(msg)? true: false);
        }
Esempio n. 13
0
 private void btnItemDel_Click(object sender, EventArgs e)
 {
     if (APConfig.SweetAlert(ShowBoxType.confirm, "是否確定要刪除?"))
     {
         foreach (DataGridViewRow row in dgvItem.SelectedRows)
         {
             dgvItem.Rows.RemoveAt(row.Index);
         }
     }
     loadTotalAmount();
 }
Esempio n. 14
0
        private void itemInfoAdd()
        {
            #region 判斷
            string msg = "";
            if (string.IsNullOrEmpty(serno))
            {
                msg = "請選取進貨單!";
            }
            else if (string.IsNullOrEmpty(txtExportAmount.Text))
            {
                msg = "請輸入出貨金額";
            }
            else if (!int.TryParse(txtExportAmount.Text, out int n))
            {
                msg = "出貨金額欄位請輸入數字";
            }
            else if (dpkExportDTTM.Value < dpkImportDTTM.Value)
            {
                msg = "出貨日期無法小於進貨日期!";
            }


            //條碼不行重複!!!!
            InventoryInfo view = new InventoryInfo(APConfig.Conn);
            view.Conditions  = " 1=1 ";
            view.Conditions += " AND " + view.getCondition(InventoryInfo.ncConditions.status.ToString(), InventoryStatus.已出貨.ToString());
            view.Conditions += " AND " + view.getCondition(InventoryInfo.ncConditions.code.ToString(), txtCode.Text);
            if (view.calculateCount() > 0)
            {
                msg = "該條碼已經被使用!";
            }

            foreach (DataGridViewRow row in dgvItem.Rows)
            {
                if (txtCode.Text == row.Cells["dgvItem_Code"].Value.ToString())
                {
                    msg = "該條碼已經被使用!";
                    break;
                }
            }


            if (!string.IsNullOrEmpty(msg))
            {
                APConfig.SweetAlert(ShowBoxType.alert, msg);
                return;
            }
            #endregion
            DataGridViewRowCollection rows = dgvItem.Rows;
            rows.Add(new Object[] { serno, txtCode.Text, txtName.Text, txtImportAmount.Text, txtExportAmount.Text, ddlDealer.SelectedItem.ToString(), dpkExportDTTM.Value.ToShortDateString(), txtExportComment.Text });
            clearTextBox();
            loadTotalAmount();
        }
Esempio n. 15
0
        private bool checkLogin()
        {
            string msg     = "";
            string pattern = @"^[a-zA-Z0-9]+$"; //判斷只有英文數字

            if (!Regex.Match(txtLoginAccount.Text, pattern).Success || !Regex.Match(txtLoginPassword.Text, pattern).Success)
            {
                APConfig.SweetAlert(ShowBoxType.alert, "欄位內容只能包含英文數字!");
                return(false);
            }
            return(true);
        }
Esempio n. 16
0
 private void btnSubmit_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(checkSubmit()))
     {
         Account entAccount = new Account(APConfig.Conn);
         entAccount.ACT_SERNO      = My.GenSerNo();
         entAccount.ACT_NAME       = txtName.Text;
         entAccount.ACT_ACCOUNT    = txtAccount.Text;
         entAccount.ACT_PASSWORD   = txtPassword.Text;
         entAccount.ACT_CREATEDTTM = DateTime.Now;
         entAccount.insert();
         APConfig.SweetAlert(ShowBoxType.alert, "新增完成!");
     }
 }
Esempio n. 17
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (mode == mode.Add && check())
     {
         Phrase ent = new Phrase(APConfig.Conn);
         ent.PHS_SERNO        = My.GenSerNo();
         ent.PHS_CATEGORY     = ddlCategory.SelectedItem.ToString();
         ent.PHS_NAME         = txtName.Text;
         ent.PHS_INDEX        = txtIndex.Text;
         ent.PHS_TYPE         = txtType.Text;
         ent.PHS_MODIFIEDBY   = APConfig.AccountName;
         ent.PHS_MODIFIEDDTTM = DateTime.Now;
         ent.insert();
         APConfig.SweetAlert(ShowBoxType.alert, "新增完成");
         this.DialogResult = DialogResult.OK;
         this.Close();
     }
     else if (mode == mode.Edit && check())
     {
         Phrase ent = new Phrase(APConfig.Conn);
         ent.PHS_SERNO    = serno;
         ent.ModifyFields = string.Format("{0};{1};{2};{3};{4}"
                                          , Phrase.ncFields.PHS_NAME.ToString()
                                          , Phrase.ncFields.PHS_INDEX.ToString()
                                          , Phrase.ncFields.PHS_TYPE.ToString()
                                          , Phrase.ncFields.PHS_MODIFIEDBY.ToString()
                                          , Phrase.ncFields.PHS_MODIFIEDDTTM.ToString());
         ent.PHS_NAME         = txtName.Text;
         ent.PHS_INDEX        = txtIndex.Text;
         ent.PHS_TYPE         = txtType.Text;
         ent.PHS_MODIFIEDBY   = APConfig.AccountName;
         ent.PHS_MODIFIEDDTTM = DateTime.Now;
         ent.update();
         APConfig.SweetAlert(ShowBoxType.alert, "修改完成");
         this.DialogResult = DialogResult.OK;
         this.Close();
     }
     else if (mode == mode.View)
     {
         this.DialogResult = DialogResult.OK;
         this.Close();
     }
     else
     {
         return;
     }
 }
Esempio n. 18
0
 public static ComboBox loadPage(ComboBox c, int maxPage)
 {
     c.Items.Clear();
     for (int i = 1; i <= maxPage; i++)
     {
         c.Items.Add(i.ToString());
     }
     if (c.Items.Count > 0)
     {
         c.SelectedIndex = 0;
     }
     else
     {
         APConfig.SweetAlert(ShowBoxType.alert, "查無資料");
     }
     return(c);
 }
Esempio n. 19
0
        private void submit()
        {
            RosterInfo vRoster = new RosterInfo(APConfig.Conn);

            vRoster.Conditions = vRoster.getCondition(RosterInfo.ncConditions.main.ToString(), txtMain.Text);
            if (!vRoster.load())
            {
                APConfig.SweetAlert(ShowBoxType.alert, "查無此主要號碼");
            }
            else
            {
                this.Hide();
                TradeEdit form = new TradeEdit(mode.Add, "", vRoster);
                form.ShowDialog();
                this.Close();
            }
        }
Esempio n. 20
0
        private string checkSubmit()
        {
            string msg     = "";
            string pattern = @"^[a-zA-Z0-9]+$"; //判斷只有英文數字
            bool   isEmpty = false;

            foreach (Control pages in this.Controls)
            {
                if (pages is Panel)
                {
                    Panel panel = pages as Panel;
                    if (panel.Name.ToString() == "panelSubmit")
                    {
                        foreach (Control c in pages.Controls)
                        {
                            if (c is BunifuMetroTextbox)
                            {
                                BunifuMetroTextbox textBox = c as BunifuMetroTextbox;
                                if (textBox.Text == string.Empty)
                                {
                                    msg     = "欄位不能為空值!";
                                    isEmpty = true;
                                }
                                else if (!Regex.Match(textBox.Text, pattern).Success)
                                {
                                    msg     = "欄位內容只能包含英文數字!";
                                    isEmpty = true;
                                }
                            }
                        }
                    }
                }
            }

            if (!isEmpty && txtPassword.Text != txtPassword2.Text)
            {
                msg = "密碼輸入不相同!";
            }

            if (!string.IsNullOrEmpty(msg))
            {
                APConfig.SweetAlert(ShowBoxType.alert, msg);
            }
            return(msg);
        }
Esempio n. 21
0
 private void loadPostSerno(string serno)
 {
     if (string.IsNullOrEmpty(serno))
     {
         APConfig.SweetAlert(ShowBoxType.alert, "寄存品載入失敗!聯繫Hugo!");
     }
     else
     {
         InventoryInfo view = new InventoryInfo(APConfig.Conn);
         view.Conditions  = " 1=1 ";
         view.Conditions += " AND " + view.getCondition(InventoryInfo.ncConditions.serno.ToString(), serno);
         if (view.load())
         {
             txtName.Text   = view.INV_NAME;
             txtAmount.Text = view.INV_POSTAMT.ToString();
             postSerno      = view.INV_SERNO;
         }
     }
 }
Esempio n. 22
0
        private void itemInfoAdd()
        {
            #region 判斷
            string msg = "";
            if (string.IsNullOrEmpty(serno))
            {
                msg = "請選取庫存!";
            }
            else if (string.IsNullOrEmpty(txtReturnAmount.Text))
            {
                msg = "請輸入退貨金額";
            }
            else if (!int.TryParse(txtReturnAmount.Text, out int n))
            {
                msg = "退貨金額欄位請輸入數字";
            }
            else if (dpkReturnDTTM.Value < dpkDTTM.Value)
            {
                msg = "出貨日期無法小於進貨日期!";
            }

            foreach (DataGridViewRow row in dgvItem.Rows)
            {
                if (serno == row.Cells["dgvItem_Serno"].Value.ToString())
                {
                    msg = "該筆資料已存在列表!";
                    break;
                }
            }

            if (!string.IsNullOrEmpty(msg))
            {
                APConfig.SweetAlert(ShowBoxType.alert, msg);
                return;
            }
            #endregion
            DataGridViewRowCollection rows = dgvItem.Rows;
            rows.Add(new Object[] { serno, txtCode.Text, txtName.Text, txtReturnAmount.Text, dpkReturnDTTM.Value.ToShortDateString(), txtReturnComment.Text });
            clearPage();
            loadRowColor();
            loadTotalAmount();
        }
Esempio n. 23
0
        private void dgvInventory_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridViewRow row    = this.dgvInventory.SelectedRows[0];
            string          status = row.Cells["dgvInventory_Status"].Value.ToString();

            if (status == InventoryStatus.已出貨.ToString())
            {
                this.Hide();
                InventoryExportEdit form = new InventoryExportEdit(mode, row.Cells["dgvInventory_Serno"].Value.ToString());
                form.ShowDialog();
                this.Close();
            }
            else if (status == InventoryStatus.庫存中.ToString())
            {
                this.Hide();
                InventoryImportEdit form = new InventoryImportEdit(mode, row.Cells["dgvInventory_Serno"].Value.ToString());
                form.ShowDialog();
                this.Close();
            }
            else if (status == InventoryStatus.寄庫品.ToString())
            {
                this.Hide();
                InventoryPostEdit form = new InventoryPostEdit(mode, row.Cells["dgvInventory_Serno"].Value.ToString());
                form.ShowDialog();
                this.Close();
            }
            else if (status == InventoryStatus.進貨退出.ToString())
            {
                this.Hide();
                InventoryReturnEdit form = new InventoryReturnEdit(mode, row.Cells["dgvInventory_Serno"].Value.ToString());
                form.ShowDialog();
                this.Close();
            }
            else
            {
                APConfig.SweetAlert(ShowBoxType.alert, "請聯繫Hugo!");
                this.Close();
            }
        }
Esempio n. 24
0
        private void txtMain_Leave(object sender, EventArgs e)
        {
            RosterInfo vRoster = new RosterInfo(APConfig.Conn);

            vRoster.Conditions = vRoster.getCondition(RosterInfo.ncConditions.main.ToString(), txtMain.Text);
            if (txtMain.Text.Length > 10)
            {
                APConfig.SweetAlert(ShowBoxType.alert, "此主要號碼不符合(市話/手機)格式!");
                txtMain.Text = "";
                txtMain.Focus();
            }
            else if (vRoster.calculateCount() > 0)
            {
                APConfig.SweetAlert(ShowBoxType.alert, "此主要號碼已經被使用!");
                txtMain.Text = "";
                txtMain.Focus();
            }
            else
            {
                txtMobile.Text = txtMain.Text.Length == 10 ? txtMain.Text : "";
                txtPhone1.Text = txtMain.Text.Length < 10 ? txtMain.Text : "";
            }
        }
Esempio n. 25
0
        private void btnBackUp_Click(object sender, EventArgs e)
        {
            if (APConfig.SweetAlert(ShowBoxType.confirm, "是否確定要備份?"))
            {
                try
                {
                    SqlConnection conn = new SqlConnection(APConfig.Conn.getConnectionString());
                    SqlCommand    cmd  = new SqlCommand(string.Empty, conn);
                    conn.Open();

                    cmd.Parameters.Clear();
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.CommandText = "sp_BackupData";

                    SqlParameter result = cmd.Parameters.Add("@result", SqlDbType.Int);
                    result.Direction = ParameterDirection.Output;

                    cmd.ExecuteNonQuery();
                    if (Convert.ToInt32(result.Value) == 1)
                    {
                        APConfig.SweetAlert(ShowBoxType.alert, "備份成功!");
                    }
                    else
                    {
                        APConfig.SweetAlert(ShowBoxType.alert, "備份失敗!");
                    }


                    conn.Close();
                    conn.Dispose();
                }
                catch (Exception ex)
                {
                    APConfig.SweetAlert(ShowBoxType.alert, string.Format("備份失敗!{0}", ex.Message));
                }
            }
        }
Esempio n. 26
0
        private void itemInfoAdd()
        {
            #region 判斷
            int    count = 0;
            string msg   = "";
            if (string.IsNullOrEmpty(txtAmount.Text))
            {
                msg = "請輸入寄庫金額";
            }
            else if (!int.TryParse(txtAmount.Text, out int n))
            {
                msg = "金額欄位請輸入數字";
            }
            else if (!int.TryParse(txtCount.Text, out count))
            {
                msg = "數量欄位請輸入數字";
            }
            else if (string.IsNullOrEmpty(txtName.Text))
            {
                msg = "請輸入商品名稱";
            }

            if (!string.IsNullOrEmpty(msg))
            {
                APConfig.SweetAlert(ShowBoxType.alert, msg);
                return;
            }
            #endregion

            DataGridViewRowCollection rows = dgvItem.Rows;
            for (int i = 0; i < count; i++)
            {
                rows.Add(new Object[] { txtName.Text, txtAmount.Text, dpkImportDTTM.Value.ToShortDateString(), txtComment.Text });
            }
            clearPage();
            loadTotalAmount();
        }
Esempio n. 27
0
        private bool checkAdd()
        {
            string msg = "";

            if (mode == mode.Add && dgvItem.RowCount <= 0)
            {
                msg = "商品資訊無法為空!";
            }
            else if (mode == mode.Edit && string.IsNullOrEmpty(txtExportAmount.Text))
            {
                msg = "商品金額無法為空!";
            }
            else if (dpkExportDTTM.Value < dpkImportDTTM.Value)
            {
                msg = "出貨日期無法小於進貨日期!";
            }


            if (!string.IsNullOrEmpty(msg))
            {
                APConfig.SweetAlert(ShowBoxType.alert, msg);
            }
            return(string.IsNullOrEmpty(msg) ? true : false);
        }
Esempio n. 28
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (mode == mode.Add && checkAdd())
            {
                int newCount = 0, postCount = 0;
                foreach (DataGridViewRow row in dgvItem.Rows)
                {
                    //寄庫存進貨
                    if (!string.IsNullOrEmpty(row.Cells["dgvItem_Serno"].Value.ToString()))
                    {
                        Inventory ent = new Inventory(APConfig.Conn);
                        ent.INV_SERNO    = row.Cells["dgvItem_Serno"].Value.ToString();
                        ent.ModifyFields = string.Format("{0};{1};{2};{3};{4};{5};{6};{7}"
                                                         , Inventory.ncFields.INV_STATUS.ToString()
                                                         , Inventory.ncFields.INV_NAME.ToString()
                                                         , Inventory.ncFields.INV_CODE.ToString()
                                                         , Inventory.ncFields.INV_INAMT.ToString()
                                                         , Inventory.ncFields.INV_INDTTM.ToString()
                                                         , Inventory.ncFields.INV_INCOMMENT.ToString()
                                                         , Inventory.ncFields.INV_MODIFIEDBY.ToString()
                                                         , Inventory.ncFields.INV_MODIFIEDDTTM.ToString());
                        ent.INV_STATUS       = InventoryStatus.庫存中.ToString();
                        ent.INV_CODE         = row.Cells["dgvItem_Code"].Value.ToString();
                        ent.INV_NAME         = row.Cells["dgvItem_Name"].Value.ToString();
                        ent.INV_INAMT        = Convert.ToInt32(row.Cells["dgvItem_Amount"].Value);
                        ent.INV_INDTTM       = DateTime.Parse(row.Cells["dgvItem_ImportDTTM"].Value.ToString());
                        ent.INV_INCOMMENT    = row.Cells["dgvItem_Comment"].Value.ToString();
                        ent.INV_MODIFIEDBY   = APConfig.AccountName;
                        ent.INV_MODIFIEDDTTM = DateTime.Now;
                        postCount           += ent.update();
                    }

                    else
                    {
                        Inventory ent = new Inventory(APConfig.Conn);
                        ent.INV_SERNO        = My.GenSerNo();
                        ent.INV_STATUS       = InventoryStatus.庫存中.ToString();
                        ent.INV_CODE         = row.Cells["dgvItem_Code"].Value.ToString();
                        ent.INV_NAME         = row.Cells["dgvItem_Name"].Value.ToString();
                        ent.INV_INCOMMENT    = row.Cells["dgvItem_Comment"].Value.ToString();
                        ent.INV_INAMT        = Convert.ToInt32(row.Cells["dgvItem_Amount"].Value);
                        ent.INV_INDTTM       = DateTime.Parse(row.Cells["dgvItem_ImportDTTM"].Value.ToString());
                        ent.INV_MODIFIEDBY   = APConfig.AccountName;
                        ent.INV_MODIFIEDDTTM = DateTime.Now;
                        newCount            += ent.insert();
                    }
                }
                APConfig.SweetAlert(ShowBoxType.alert, string.Format("進貨完成!\r\n新增 {0} 件進貨單 和 {1} 件寄庫存進貨單", newCount.ToString(), postCount.ToString()));
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            else if (mode == mode.Edit && checkAdd())
            {
                Inventory ent = new Inventory(APConfig.Conn);
                ent.INV_SERNO    = serno;
                ent.ModifyFields = string.Format("{0};{1};{2};{3};{4};{5}"
                                                 , Inventory.ncFields.INV_NAME.ToString()
                                                 , Inventory.ncFields.INV_INAMT.ToString()
                                                 , Inventory.ncFields.INV_INDTTM.ToString()
                                                 , Inventory.ncFields.INV_INCOMMENT.ToString()
                                                 , Inventory.ncFields.INV_MODIFIEDBY.ToString()
                                                 , Inventory.ncFields.INV_MODIFIEDDTTM.ToString());
                ent.INV_NAME         = txtName.Text;
                ent.INV_INAMT        = Convert.ToInt32(txtAmount.Text);
                ent.INV_INDTTM       = DateTime.Parse(dpkImportDTTM.Value.ToString());
                ent.INV_INCOMMENT    = txtComment.Text;
                ent.INV_MODIFIEDBY   = APConfig.AccountName;
                ent.INV_MODIFIEDDTTM = DateTime.Now;
                ent.update();
                APConfig.SweetAlert(ShowBoxType.alert, "修改完成");
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            else if (mode == mode.View)
            {
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            else
            {
                return;
            }
        }
Esempio n. 29
0
        private void itemInfoAdd()
        {
            #region 判斷
            string msg = "";
            if (string.IsNullOrEmpty(txtAmount.Text))
            {
                msg = "請輸入金額";
            }
            else if (!int.TryParse(txtAmount.Text, out int n))
            {
                msg = "金額欄位請輸入數字";
            }
            else if (string.IsNullOrEmpty(txtCode.Text))
            {
                msg = "請輸入商品代碼";
            }
            else if (string.IsNullOrEmpty(txtName.Text))
            {
                msg = "請輸入商品名稱";
            }

            //進階判斷
            if (string.IsNullOrEmpty(msg))
            {
                //條碼不行重複!!!!
                InventoryInfo view = new InventoryInfo(APConfig.Conn);
                view.Conditions  = " 1=1 ";
                view.Conditions += " AND " + view.getCondition(InventoryInfo.ncConditions.code.ToString(), txtCode.Text);
                if (view.calculateCount() > 0)
                {
                    msg = "該條碼已經被使用!";
                }

                foreach (DataGridViewRow row in dgvItem.Rows)
                {
                    if (txtCode.Text == row.Cells["dgvItem_Code"].Value.ToString())
                    {
                        msg = "該條碼已經被使用!";
                        break;
                    }
                    else if (!string.IsNullOrEmpty(postSerno) && postSerno == row.Cells["dgvItem_Serno"].Value.ToString())
                    {
                        msg = "該寄庫品已重複!";
                        break;
                    }
                }
            }

            if (!string.IsNullOrEmpty(msg))
            {
                APConfig.SweetAlert(ShowBoxType.alert, msg);
                return;
            }
            #endregion


            DataGridViewRowCollection rows = dgvItem.Rows;
            rows.Add(new Object[] { postSerno, txtCode.Text, txtName.Text, txtAmount.Text, dpkImportDTTM.Value.ToShortDateString(), txtComment.Text });
            postSerno = "";
            clearPage();
            loadTotalAmount();
            loadRowColor();
        }
Esempio n. 30
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (mode == mode.Add && checkAdd())
     {
         foreach (DataGridViewRow row in dgvItem.Rows)
         {
             RosterDial ent = new RosterDial(APConfig.Conn);
             ent.RSD_SERNO        = My.GenSerNo();
             ent.RST_SERNO        = mRosterInfo.RST_SERNO;
             ent.RSD_STATUS       = ddlStatus.SelectedItem.ToString();
             ent.RSD_ITEMTYPE     = row.Cells["dgvItem_Type"].Value.ToString();
             ent.RSD_ITEM         = row.Cells["dgvItem_Item"].Value.ToString();
             ent.RSD_AMOUNT       = row.Cells["dgvItem_Amount"].Value.ToString();
             ent.RSD_COMMENT      = txtComment.Text;
             ent.RSD_DEALER       = ddlDealer.SelectedItem.ToString();
             ent.RSD_MODIFIEDBY   = APConfig.AccountName;
             ent.RSD_MODIFIEDDTTM = DateTime.Now;
             ent.RSD_INSERTBY     = APConfig.AccountName;
             ent.RSD_INSERTDTTM   = DateTime.Now;
             ent.RSD_DEALDDTTM    = DateTime.Parse(dpkDealDTTM.Value.ToString());
             ent.insert();
         }
         APConfig.SweetAlert(ShowBoxType.alert, "新增完成");
         this.DialogResult = DialogResult.OK;
         this.Close();
     }
     else if (mode == mode.Edit && checkAdd())
     {
         RosterDial ent = new RosterDial(APConfig.Conn);
         ent.RSD_SERNO    = serno;
         ent.ModifyFields = string.Format("{0};{1};{2};{3};{4};{5};{6};{7};{8}"
                                          , RosterDial.ncFields.RSD_DEALER.ToString()
                                          , RosterDial.ncFields.RSD_STATUS.ToString()
                                          , RosterDial.ncFields.RSD_ITEMTYPE.ToString()
                                          , RosterDial.ncFields.RSD_ITEM.ToString()
                                          , RosterDial.ncFields.RSD_AMOUNT.ToString()
                                          , RosterDial.ncFields.RSD_COMMENT.ToString()
                                          , RosterDial.ncFields.RSD_MODIFIEDBY.ToString()
                                          , RosterDial.ncFields.RSD_MODIFIEDDTTM.ToString()
                                          , RosterDial.ncFields.RSD_DEALDDTTM.ToString());
         ent.RSD_DEALER       = ddlDealer.SelectedItem.ToString();
         ent.RSD_STATUS       = ddlStatus.SelectedItem.ToString();
         ent.RSD_ITEMTYPE     = ddlType.SelectedItem.ToString();
         ent.RSD_ITEM         = txtItemInfo.Text;
         ent.RSD_AMOUNT       = txtAmount.Text;
         ent.RSD_COMMENT      = txtComment.Text;
         ent.RSD_MODIFIEDBY   = APConfig.AccountName;
         ent.RSD_MODIFIEDDTTM = DateTime.Now;
         ent.RSD_DEALDDTTM    = DateTime.Parse(dpkDealDTTM.Value.ToString());
         ent.update();
         APConfig.SweetAlert(ShowBoxType.alert, "修改完成");
         this.DialogResult = DialogResult.OK;
         this.Close();
     }
     else if (mode == mode.View)
     {
         this.DialogResult = DialogResult.OK;
         this.Close();
     }
     else
     {
         return;
     }
 }