예제 #1
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);
        }
예제 #2
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 : "";
            }
        }
예제 #3
0
파일: MemberEdit.cs 프로젝트: zlmone/Speed
        private bool checkAdd()
        {
            string msg = "";
            int    n, count = 0;

            string[] condReqName    = { "txtMobile1", "txtMobile2", "txtPhone" }; //判斷欄位三個至少填一個
            string[] condName       = { "txtName", "txtNo" };                     //必填欄位
            string[] condNumberName = { "txtAmount" };                            //判斷數字欄位
            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 = "必要欄位不能為空值!";
                    }
                    else if (condReqName.Contains(textBox.Name) && textBox.Text == string.Empty)
                    {
                        count++;
                    }
                    else if (condNumberName.Contains(textBox.Name) && textBox.Text != string.Empty)
                    {
                        if (!int.TryParse(textBox.Text, out n))
                        {
                            msg = "金額欄位請輸入數字";
                        }
                    }
                }
                else if (c is BunifuDropdown)
                {
                    BunifuDropdown dropdown = c as BunifuDropdown;
                    if (dropdown.selectedIndex == -1)
                    {
                        msg = "欄位不能為空值!";
                    }
                }
            }

            if (count == condReqName.Length)
            {
                msg = "電話欄位至少輸入一欄!";
            }
            if (string.IsNullOrEmpty(msg) && mode == mode.Add)
            {
                foreach (DataGridViewRow row in dgvItem.Rows)
                {
                    if (txtNo.Text == row.Cells["dgvItem_No"].Value.ToString())
                    {
                        msg = "該訂單編號已經存在列表中!請重複確認!!";
                        break;
                    }
                }
            }
            if (string.IsNullOrEmpty(msg) && mode == mode.Add)
            {
                RosterInfo vRoster = new RosterInfo(APConfig.Conn);
                vRoster.Conditions = vRoster.getCondition(RosterInfo.ncConditions.no.ToString(), txtNo.Text);
                if (vRoster.calculateCount() > 0)
                {
                    msg = "該訂單編號已經有資料!請重複確認!";
                }
            }

            if (!string.IsNullOrEmpty(msg))
            {
                APConfig.SweetAlert(ShowBoxType.alert, msg);
            }
            return(string.IsNullOrEmpty(msg) ? true : false);
        }
예제 #4
0
        private void memberLoadData(int pageNum)
        {
            int total = 0;

            dgvMember.Rows.Clear();
            DataGridViewRowCollection rows = dgvMember.Rows;
            RosterInfo vRoster             = new RosterInfo(APConfig.Conn);

            vRoster.Conditions = " 1=1 ";
            if (!string.IsNullOrEmpty(txtMemberName.Text))
            {
                vRoster.Conditions += " AND " + vRoster.getCondition(RosterInfo.ncConditions.name.ToString(), txtMemberName.Text);
            }
            if (!string.IsNullOrEmpty(txtMemberTel.Text))
            {
                vRoster.Conditions += " AND " + vRoster.getCondition(RosterInfo.ncConditions.phoneLike.ToString(), txtMemberTel.Text);
            }
            if (!string.IsNullOrEmpty(txtMemberAddr.Text))
            {
                vRoster.Conditions += " AND " + vRoster.getCondition(RosterInfo.ncConditions.address.ToString(), txtMemberAddr.Text);
            }
            if (!string.IsNullOrEmpty(txtMemberNo.Text))
            {
                vRoster.Conditions += " AND " + vRoster.getCondition(RosterInfo.ncConditions.noLike.ToString(), txtMemberNo.Text);
            }
            if (!string.IsNullOrEmpty(dpkMemberOrderSDTTM.Value.ToString()) && ckbMemberOrderDTTM.Checked)
            {
                vRoster.Conditions += " AND " + vRoster.getCondition(RosterInfo.ncConditions.orderSDTTM.ToString(), dpkMemberOrderSDTTM.Value.ToString("yyyy/MM/dd"));
            }
            if (!string.IsNullOrEmpty(dpkMemberOrderEDTTM.Value.ToString()) && ckbMemberOrderDTTM.Checked)
            {
                vRoster.Conditions += " AND " + vRoster.getCondition(RosterInfo.ncConditions.orderEDTTM.ToString(), dpkMemberOrderEDTTM.Value.ToString("yyyy/MM/dd"));
            }
            //組排序指令
            if (dgvMember.SortedColumn == null)
            {
                vRoster.OrderBy = vRoster.getOptionOrderBy(RosterInfo.ncSort.Default.ToString());
            }
            else
            {
                string sortname = dgvMember.SortedColumn.Name;
                string sortmode = APConfig.GetValueFromDescription <SortMode>(dgvMember.SortOrder.ToString()).ToString();
                vRoster.OrderBy = string.Format("{0} {1}", vRoster.getOptionOrderBy(sortname), sortmode);
            }
            //查詢頁數初始化且自動跳轉至第一頁
            if (pageNum == 0)
            {
                APConfig.loadPage(ddlMemberPage, vRoster.calculatePage(APConfig.PageCount));
                return;
            }
            //塞入資料
            lblMemberTotal.Text = vRoster.calculateCount().ToString();
            DataSet ds = APConfig.GoPage(vRoster.SQLStatement, pageNum);

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                rows.Add(new Object[] { dr.ItemArray[0], dr.ItemArray[1], dr.ItemArray[2], dr.ItemArray[4], dr.ItemArray[5], dr.ItemArray[3], dr.ItemArray[6], dr.ItemArray[10], dr.ItemArray[11], dr.ItemArray[12] });
            }

            //計算總金額
            vRoster.load();
            while (!vRoster.IsEof)
            {
                total += vRoster.RST_AMOUNT;
                vRoster.next();
            }
            lblMemberAMTTotal.Text = string.Format("{0} 元", total.ToString());
        }
예제 #5
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (mode == mode.Add && checkAdd())
     {
         RosterInfo vRoster = new RosterInfo(APConfig.Conn);
         vRoster.Conditions = vRoster.getCondition(RosterInfo.ncConditions.main.ToString(), txtMain.Text);
         if (vRoster.calculateCount() == 0)
         {
             Roster entRoster = new Roster(APConfig.Conn);
             entRoster.RST_SERNO        = My.GenSerNo();
             entRoster.RST_NAME         = txtName.Text;
             entRoster.RST_MAIN         = txtMain.Text;
             entRoster.RST_SEX          = ddlSex.SelectedItem.ToString();
             entRoster.RST_PHONE1       = txtPhone1.Text;
             entRoster.RST_PHONE2       = txtPhone2.Text;
             entRoster.RST_MOBILE       = txtMobile.Text;
             entRoster.RST_FAX          = txtFax.Text;
             entRoster.RST_ADDR         = txtAddr.Text;
             entRoster.RST_PRINCIPAL    = ddlPrinciple.SelectedItem.ToString();
             entRoster.RST_COMMENT      = txtComment.Text;
             entRoster.RST_MODIFIEDBY   = APConfig.AccountName;
             entRoster.RST_MODIFIEDDTTM = DateTime.Now;
             entRoster.RST_INSERTBY     = APConfig.AccountName;
             entRoster.RST_INSERTDTTM   = DateTime.Now;
             entRoster.insert();
             APConfig.SweetAlert(ShowBoxType.alert, "新增完成");
             this.DialogResult = DialogResult.OK;
             this.Close();
         }
         else
         {
             APConfig.SweetAlert(ShowBoxType.alert, "主要號碼已經存在");
             txtMain.Focus();
         }
     }
     else if (mode == mode.Edit && checkAdd())
     {
         Roster entRoster = new Roster(APConfig.Conn);
         entRoster.RST_SERNO    = serno;
         entRoster.ModifyFields = string.Format("{0};{1};{2};{3};{4};{5};{6};{7};{8};{9};{10}"
                                                , Roster.ncFields.RST_NAME.ToString()
                                                , Roster.ncFields.RST_MAIN.ToString()
                                                , Roster.ncFields.RST_SEX.ToString()
                                                , Roster.ncFields.RST_PHONE1.ToString()
                                                , Roster.ncFields.RST_PHONE2.ToString()
                                                , Roster.ncFields.RST_FAX.ToString()
                                                , Roster.ncFields.RST_ADDR.ToString()
                                                , Roster.ncFields.RST_PRINCIPAL.ToString()
                                                , Roster.ncFields.RST_COMMENT.ToString()
                                                , Roster.ncFields.RST_MODIFIEDBY.ToString()
                                                , Roster.ncFields.RST_MODIFIEDDTTM.ToString());
         entRoster.RST_NAME         = txtName.Text;
         entRoster.RST_MAIN         = txtMain.Text;
         entRoster.RST_SEX          = ddlSex.SelectedItem.ToString();
         entRoster.RST_PHONE1       = txtPhone1.Text;
         entRoster.RST_PHONE2       = txtPhone2.Text;
         entRoster.RST_FAX          = txtFax.Text;
         entRoster.RST_ADDR         = txtAddr.Text;
         entRoster.RST_PRINCIPAL    = ddlPrinciple.SelectedItem.ToString();
         entRoster.RST_COMMENT      = txtComment.Text;
         entRoster.RST_MODIFIEDBY   = APConfig.AccountName;
         entRoster.RST_MODIFIEDDTTM = DateTime.Now;
         entRoster.update();
         APConfig.SweetAlert(ShowBoxType.alert, "修改完成");
         this.DialogResult = DialogResult.OK;
         this.Close();
     }
     else if (mode == mode.View)
     {
         this.DialogResult = DialogResult.OK;
         this.Close();
     }
     else
     {
         return;
     }
 }