Esempio n. 1
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. 2
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. 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 btnMemberLeft_Click(object sender, EventArgs e)
 {
     if (APConfig.prevPage(ref ddlMemberPage))
     {
         memberLoadData(ddlMemberPage.SelectedIndex + 1);
     }
 }
Esempio n. 5
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. 6
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. 7
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. 8
0
 public PickInventoryCode(mode pmode, string pSernoList)
 {
     InitializeComponent();
     mode      = pmode;
     sernolist = APConfig.sqlArrayFormat(pSernoList);
     loadData();
 }
Esempio n. 9
0
 private void btnInventoryLeft_Click(object sender, EventArgs e)
 {
     if (APConfig.prevPage(ref ddlInventoryPage))
     {
         inventoryLoadData(ddlInventoryPage.SelectedIndex + 1);
     }
 }
Esempio n. 10
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. 11
0
 private void inventoryInitial()
 {
     dgvInventory.Rows.Clear();
     APConfig.loadPhrase(ddlInventoryDealer, PhraseCategory.案件負責人.ToString(), true);
     APConfig.loadEnum <InventoryStatus>(ddlInventoryStatus, "", true);
     txtInventoryCode.Text            = string.Empty;
     txtInventoryName.Text            = string.Empty;
     ckbInventoryINDTTM.Checked       = false;
     ckbInventoryOUTDTTM.Checked      = false;
     ckbInventoryPOSTDTTM.Checked     = false;
     ckbInventoryRETURNDTTM.Checked   = false;
     ddlInventoryDealer.SelectedIndex = 0;
     ddlInventoryStatus.SelectedIndex = 0;
     dpkInventoryINSDTTM.Value        = DateTime.Today;
     dpkInventoryINEDTTM.Value        = DateTime.Today;
     dpkInventoryOUTEDTTM.Value       = DateTime.Today;
     dpkInventoryOUTSDTTM.Value       = DateTime.Today;
     dpkInventoryRETURNSDTTM.Value    = DateTime.Today;
     dpkInventoryRETURNEDTTM.Value    = DateTime.Today;
     dpkInventoryPOSTSDTTM.Value      = DateTime.Today;
     dpkInventoryPOSTEDTTM.Value      = DateTime.Today;
     lblInventoryINAMT.Text           = "0 元";
     lblInventoryOUTAMT.Text          = "0 元";
     lblInventoryPOSTAMT.Text         = "0 元";
     lblInventoryRETURNAMT.Text       = "0 元";
     lblInventoryTotal.Text           = "0";
     ddlInventoryPage.Items.Clear();
 }
Esempio n. 12
0
 private void btnSaleLeft_Click(object sender, EventArgs e)
 {
     if (APConfig.prevPage(ref ddlSalePage))
     {
         saleLoadData(ddlSalePage.SelectedIndex + 1);
     }
 }
Esempio n. 13
0
 private void saleInitial()
 {
     dgvSale.Rows.Clear();
     APConfig.loadPhrase(ddlSaleDealer, PhraseCategory.案件負責人.ToString(), true);
     APConfig.loadPhrase(ddlSaleType, PhraseCategory.收入類別.ToString(), true);
     txtSaleItem.Text            = string.Empty;
     txtSaleMain.Text            = string.Empty;
     txtSaleName.Text            = string.Empty;
     txtSaleComment.Text         = string.Empty;
     ddlSaleDealer.SelectedIndex = 0;
     ddlSaleStatus.SelectedIndex = 0;
     ddlSaleType.SelectedIndex   = 0;
     ddlSaleType.Items.Add("銷貨淨值");
     ckbSaleModifyDTTM.Checked = false;
     ckbSaleDealDTTM.Checked   = false;
     dpkSaleDealEDTTM.Value    = DateTime.Today;
     dpkSaleDealSDTTM.Value    = DateTime.Today;
     //dpkSaleInsertEDTTM.Value = DateTime.Today;
     //dpkSaleInsertSDTTM.Value = DateTime.Today;
     dpkSaleModifySDTTM.Value = DateTime.Today;
     dpkSaleModifyEDTTM.Value = DateTime.Today;
     lblSaleTotal.Text        = "0";
     lblSaleTotalAmount.Text  = "0 元";
     ddlSalePage.Items.Clear();
 }
Esempio n. 14
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. 15
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. 16
0
 private void btnClose_Click(object sender, EventArgs e)
 {
     if (APConfig.SweetAlert(ShowBoxType.confirm, "確定要離開嗎?"))
     {
         this.Close();
         Environment.Exit(Environment.ExitCode);
     }
 }
Esempio n. 17
0
 private void phraseInitial()
 {
     APConfig.loadEnum <PhraseCategory>(ddlPhraseCategory);
     dgvPhrase.Rows.Clear();
     txtPhraseName.Text  = string.Empty;
     txtPhraseType.Text  = string.Empty;
     lblPhraseTotal.Text = "0";
 }
Esempio n. 18
0
 public PhraseEdit(mode pmode, string pcategory, string pserno = "")
 {
     InitializeComponent();
     APConfig.loadEnum <PhraseCategory>(ddlCategory, pcategory);
     serno = pserno;
     mode  = pmode;
     initView();
 }
Esempio n. 19
0
 public InventoryExportEdit(mode pmode, string pserno = "")
 {
     InitializeComponent();
     APConfig.loadPhrase(ddlDealer, PhraseCategory.案件負責人.ToString());
     serno = pserno;
     mode  = pmode;
     initView();
 }
Esempio n. 20
0
        private void dgvItem_DoubleClick(object sender, EventArgs e)
        {
            DataGridViewRow row = this.dgvItem.SelectedRows[0];

            ddlType.SelectedIndex = APConfig.getSelectIndex(ddlType, row.Cells["dgvItem_Type"].Value.ToString());
            txtItemInfo.Text      = row.Cells["dgvItem_Item"].Value.ToString();
            txtAmount.Text        = row.Cells["dgvItem_Amount"].Value.ToString();
        }
Esempio n. 21
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. 22
0
        private void dgvItem_DoubleClick(object sender, EventArgs e)
        {
            DataGridViewRow row = this.dgvItem.SelectedRows[0];

            ddlDealer.SelectedIndex = APConfig.getSelectIndex(ddlDealer, row.Cells["dgvItem_Dealer"].Value.ToString());
            txtExportAmount.Text    = row.Cells["dgvItem_Amount"].Value.ToString();
            dpkExportDTTM.Value     = Convert.ToDateTime(row.Cells["dgvItem_ImportDTTM"].Value);
            txtExportComment.Text   = row.Cells["dgvItem_Comment"].Value.ToString();
        }
Esempio n. 23
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. 24
0
 public MemberEdit(mode pmode, string pserno = "")
 {
     InitializeComponent();
     APConfig.loadPhrase(ddlPrinciple, PhraseCategory.案件負責人.ToString());
     serno = pserno;
     mode  = pmode;
     initView();
     txtMain.Focus();
 }
Esempio n. 25
0
 public TradeEdit(mode pmode, string pserno = "", RosterInfo pRosterInfo = null)
 {
     InitializeComponent();
     APConfig.loadPhrase(ddlDealer, PhraseCategory.案件負責人.ToString());
     APConfig.loadPhrase(ddlType, PhraseCategory.收入類別.ToString());
     serno       = pserno;
     mode        = pmode;
     mRosterInfo = pRosterInfo;
     initView();
 }
Esempio n. 26
0
        public Home()
        {
            InitializeComponent();
            APConfig.LoadConfig();
            AccountInfo view = new AccountInfo(APConfig.Conn);

            view.load();

            int a = view.Count;
        }
Esempio n. 27
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. 28
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. 29
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. 30
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, "新增完成!");
     }
 }