Example #1
0
        void assignMaxQty(int id)
        {
            NumericUpDown  qtyCart   = ((NumericUpDown)this.Controls.Find("itemQtyCartTB" + id, true)[0]);
            BunifuDropdown name      = ((BunifuDropdown)this.Controls.Find("itemNameCombo" + id, true)[0]);
            NumericUpDown  qtyPc     = ((NumericUpDown)this.Controls.Find("itemQtyPcTB" + id, true)[0]);
            ComboBox       desc      = ((ComboBox)this.Controls.Find("itemDescCombo" + id, true)[0]);
            NumericUpDown  unitPrice = ((NumericUpDown)this.Controls.Find("itemUnitPriceTB" + id, true)[0]);
            ComboBox       expiry    = ((ComboBox)this.Controls.Find("expiry" + id, true)[0]);

            if (expiry.Items.Count == 0)
            {
                fillExpiry(id, name.selectedValue, desc.Text);
            }
            int crt     = 0;
            int maxcart = 0;
            int maxpc   = 0;

            foreach (item i in itemsList)
            {
                if (i.desc == desc.Text && i.Name == name.selectedValue && i.expiry == expiry.Text)
                {
                    qtyCart.Maximum = i.maxCart;
                    qtyPc.Maximum   = i.maxPcs;
                    unitPrice.Value = i.rate;
                    crt             = i.crt;
                    maxcart         = i.maxCart;
                    maxpc           = i.maxPcs;
                    break;
                }
            }
            modifyOrder(id, name, desc, crt, expiry, int.Parse(qtyCart.Value.ToString()), int.Parse(qtyPc.Value.ToString()), maxcart, maxpc);
            setAmount(id);
        }
Example #2
0
        bool validate()
        {
            bool validated = false;

            foreach (item i in orderList)
            {
                NumericUpDown  qtyCart    = ((NumericUpDown)this.Controls.Find("itemQtyCartTB" + i.id, true)[0]);
                NumericUpDown  qtyPc      = ((NumericUpDown)this.Controls.Find("itemQtyPcTB" + i.id, true)[0]);
                NumericUpDown  unitPrice  = ((NumericUpDown)this.Controls.Find("itemUnitPriceTB" + i.id, true)[0]);
                NumericUpDown  tradeOffer = ((NumericUpDown)this.Controls.Find("tradeOfferTB" + i.id, true)[0]);
                Label          amount     = ((Label)this.Controls.Find("totalLB" + i.id, true)[0]);
                BunifuDropdown name       = ((BunifuDropdown)this.Controls.Find("itemNameCombo" + i.id, true)[0]);
                ComboBox       desc       = ((ComboBox)this.Controls.Find("itemDescCombo" + i.id, true)[0]);
                if (qtyCart.Text == "" || qtyPc.Text == "" || unitPrice.Text == "" || tradeOffer.Text == "" ||
                    amount.Text == "" || name.selectedIndex == -1 || desc.Text == "" || !validateAmounts() || !validateBillDetails())
                {
                    validated = false;
                }
                else
                {
                    validated = true;
                }
            }
            return(validated);
        }
Example #3
0
        public Panel createItemsPanel()
        {
            Panel          itemsPanel    = new Panel();
            NumericUpDown  itemUnitPrice = createItemUnitPriceTB();
            NumericUpDown  itemQtyCart   = createItemQtyCartTB();
            NumericUpDown  itemQtyPc     = createItemQtyPcTB();
            NumericUpDown  TradeOffer    = createTradeOfferTB();
            ComboBox       itemDesc      = createItemDescCombo();
            BunifuDropdown itemName      = createItemNameCombo();
            Label          amount        = createAmount();
            Label          remove        = createRemoveSign();
            ComboBox       expiry        = createExpiryCB();

            itemsPanel.Dock = DockStyle.Top;
            //itemsPanel.BorderStyle = BorderStyle.FixedSingle;
            itemsPanel.Location = new Point(0, 0);
            itemsPanel.Name     = "itemsPanel" + numberOfItems;
            itemsPanel.Size     = new System.Drawing.Size(700, 25);
            itemsPanel.Controls.Add(itemName);
            itemsPanel.Controls.Add(itemDesc);
            itemsPanel.Controls.Add(itemQtyCart);
            itemsPanel.Controls.Add(itemUnitPrice);
            itemsPanel.Controls.Add(itemQtyPc);
            itemsPanel.Controls.Add(TradeOffer);
            itemsPanel.Controls.Add(amount);
            itemsPanel.Controls.Add(remove);
            itemsPanel.Controls.Add(expiry);
            return(itemsPanel);
        }
Example #4
0
        public void ThemDichVu(BunifuDropdown ddtenphong, BunifuDropdown ddDichVu, out int transfer)
        {
            transfer = 0;
            HotelObject.ThuePhongHo tp = new HotelObject.ThuePhongHo();
            string temp2 = null;

            tp.MaThue = conn.LayBien("EXEC PROC_SELECT_MASD", 0);
            if (tp.MaThue != null)
            {
                for (int i = 2; i < tp.MaThue.Length; i++)
                {
                    temp2 = temp2 + tp.MaThue[i];
                }
            }
            else
            {
                temp2 = "0";
            }

            tp.MaThue = "SD" + (Int32.Parse(temp2) + 1).ToString();

            conn.InsertDeleteUpdate("EXEC PROC_SELECT_THEMDICHVU N'" + ddtenphong.selectedValue + "','" + tp.MaThue + "',N'" + ddDichVu.selectedValue + "','" + DateTime.Now + "' ");
            Notification nf = new Notification("DỊCH VỤ", "Thêm dịch vụ thành công.", "");

            nf.Show();
            transfer = 1;
        }
        private int MakeDropDownString(BunifuDropdown nameforDropdown, string selectedName)
        {
            int index = nameforDropdown.Items.Select((v, i) => new { Index = i, Value = v })
                        .Where(p => p.Value == selectedName)
                        .Select(p => p.Index).FirstOrDefault();

            return(index);
        }
Example #6
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);
        }
 /* METHOD : (2)
  * ********************************************************************************************************
  * If user proceed without selecting any value from dropdown list then, select value of dropdown will by default set as other.
  * If nothing is selected return string value other else return selected value.
  * ********************************************************************************************************
  */
 public static String ValidateDropDown(BunifuDropdown dropdown)
 {
     if (dropdown.selectedIndex == 0)
     {
         return("Other");
     }
     else
     {
         return(dropdown.selectedValue);
     }
 }
Example #8
0
        public void LayTenDichVu(BunifuDropdown ddDichVu)
        {
            int n;

            string[] tendichvu = new string[100];
            conn.LayMangSql(tendichvu, "EXEC PROC_SELECT_TENDICHVU", out n, 0);
            ddDichVu.Clear();
            for (int i = 0; i < n; i++)
            {
                ddDichVu.AddItem(tendichvu[i]);
            }
            ddDichVu.selectedIndex = 0;
        }
Example #9
0
        void fillItems(BunifuDropdown name)
        {
            List <string> list = new List <string>();

            foreach (item i in itemsList)
            {
                list.Add(i.Name);
            }
            foreach (string s in list.Distinct())
            {
                name.AddItem(s);
            }
        }
Example #10
0
        void assignQty(int id)
        {
            NumericUpDown  qtyCart   = ((NumericUpDown)this.Controls.Find("itemQtyCartTB" + id, true)[0]);
            BunifuDropdown name      = ((BunifuDropdown)this.Controls.Find("itemNameCombo" + id, true)[0]);
            NumericUpDown  qtyPc     = ((NumericUpDown)this.Controls.Find("itemQtyPcTB" + id, true)[0]);
            ComboBox       desc      = ((ComboBox)this.Controls.Find("itemDescCombo" + id, true)[0]);
            NumericUpDown  unitPrice = ((NumericUpDown)this.Controls.Find("itemUnitPriceTB" + id, true)[0]);
            ComboBox       expiry    = ((ComboBox)this.Controls.Find("expiry" + id, true)[0]);

            if (name.selectedValue != "" && desc.Text != "" && expiry.Text != "")
            {
                assignNewMax(id, name, desc, expiry, qtyCart, qtyPc);
            }
        }
Example #11
0
        int getProductID(int id)
        {
            BunifuDropdown name   = ((BunifuDropdown)this.Controls.Find("itemNameCombo" + id, true)[0]);
            ComboBox       desc   = ((ComboBox)this.Controls.Find("itemDescCombo" + id, true)[0]);
            ComboBox       expiry = ((ComboBox)this.Controls.Find("expiry" + id, true)[0]);

            foreach (item i in itemsList)
            {
                if (i.Name == name.selectedValue && i.desc == desc.Text && i.expiry == expiry.Text)
                {
                    return(i.id);
                }
            }
            return(0);
        }
Example #12
0
        public void LayTenPhong(BunifuDropdown ddsotang, BunifuDropdown ddtenphong)
        {
            string[] tenphong = new string[15];
            int      m;

            conn.LayMangSql(tenphong, "EXEC PRO_SELECT_TENPHONG1 " + ddsotang.selectedValue, out m, 0);
            ddtenphong.Clear();
            for (int i = 0; i < m; i++)
            {
                ddtenphong.AddItem(tenphong[i]);
            }
            if (m != 0)
            {
                ddtenphong.selectedIndex = 0;
            }
        }
Example #13
0
 void modifyOrder(int id, BunifuDropdown name, ComboBox desc, int crt, ComboBox expiry, int qtyCart, int qtyPc, int maxCart, int maxPc)
 {
     foreach (item i in orderList)
     {
         if (i.id == id)
         {
             i.Name    = name.selectedValue;
             i.desc    = desc.Text;
             i.crt     = crt;
             i.expiry  = expiry.Text;
             i.qtycart = qtyCart;
             i.qtypcs  = qtyPc;
             i.maxCart = maxCart;
             i.maxPcs  = maxPc;
             break;
         }
     }
 }
        public void ThemNhanVien(TextBoxX tbhoten, BunifuDropdown ddGioiTinh, TextBoxX tbpass, TextBoxX tbphone, BunifuDatepicker DPNgaySinh, BunifuDropdown ddchucvu, string btavtar, out int transfer)
        {
            transfer = 0;
            HotelObject.NhanVienHo nv = new HotelObject.NhanVienHo();
            string   temp             = null;
            ChuanHoa ch = new ChuanHoa();

            nv.NgaySinh = DPNgaySinh.Value.ToString();
            ch.ChuanHoaDate(nv.NgaySinh, out day, out month, out year);
            nv.NgaySinh   = year + month + day;
            nv.MaNhanVien = conn.LayBien("EXEC PROC_SELECT_MANHANVIEN", 0);
            if (nv.MaNhanVien == "" || nv.MaNhanVien == null || nv.MaNhanVien == "1" || nv.MaNhanVien == "ADMIN")
            {
                nv.MaNhanVien = "NV1234";
            }

            for (int i = 2; i < nv.MaNhanVien.Length; i++)
            {
                temp = temp + nv.MaNhanVien[i];
            }
            nv.MaNhanVien = "NV" + (Int32.Parse(temp) + 1).ToString();
            nv.HoTen      = ch.CH_Name(tbhoten);
            if (ch.Check_Phone(tbphone) == false)
            {
                Notification nf = new Notification("LỖI", "Số điện thoại không hợp lệ", "Mời bạn nhập lại.");
                nf.Show();
                transfer = 0;
            }
            else if (ch.Check_Text_Name(tbhoten) == false)
            {
                Notification nf = new Notification("LỖI", "Tên nhập chứa chữ số", "Mời bạn nhập lại.");
                nf.Show();
                transfer = 0;
            }
            else
            {
                conn.InsertDeleteUpdate("EXEC PROC_INSERT_NHANVIEN '" + nv.MaNhanVien + "','" + tbpass.Text + "',N'" + tbhoten.Text + "',N'" + ddchucvu.selectedValue + "',N'" + ddGioiTinh.selectedValue + "',N'" + btavtar + "','" + year + month + day + "','" + tbphone.Text + "'");
                Notification nf = new Notification("THÊM NHÂN VIÊN", "Thêm nhân viên thành công.", "Mã nhân viên :" + nv.MaNhanVien);
                nf.Show();
                transfer = 1;
            }
        }
Example #15
0
        //-------------Descriptions--------------------------------------

        public BunifuDropdown createItemNameCombo()
        {
            BunifuDropdown itemNameCombo = new BunifuDropdown();

            itemNameCombo.Anchor = AnchorStyles.None;
            itemNameCombo.Font   = new Font("Microsoft Sans Serif", 9.75F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
            //itemNameCombo.FormattingEnabled = true;
            //itemNameCombo.FontWeight = MetroComboBoxWeight.Regular;
            //itemNameCombo.FontSize = MetroComboBoxSize.Small;
            itemNameCombo.Location     = new Point(2, 0);
            itemNameCombo.Name         = "itemNameCombo" + numberOfItems;
            itemNameCombo.Size         = new Size(100, 25);
            itemNameCombo.Margin       = new Padding(0);
            itemNameCombo.BorderRadius = 3;
            //itemNameCombo.DropDownStyle = ComboBoxStyle.DropDownList;
            fillItems(itemNameCombo);
            itemNameCombo.Tag             = numberOfItems;
            itemNameCombo.onItemSelected += (s, args) => addDescription(int.Parse(itemNameCombo.Tag.ToString()));
            return(itemNameCombo);
        }
Example #16
0
        void assignNewMax(int id, BunifuDropdown name, ComboBox desc, ComboBox expiry, NumericUpDown qtyCart, NumericUpDown qtyPc)
        {
            int qtycartons = 0;
            int qtypcs     = 0;

            foreach (item ii in orderList)
            {
                if (ii.id != id)
                {
                    if (name.selectedValue == ii.Name && desc.Text == ii.desc && expiry.Text == ii.expiry)
                    {
                        qtycartons += ii.qtycart;
                        qtypcs     += ii.qtypcs;
                    }
                }
            }

            qtyCart.Maximum = qtyCart.Maximum - qtycartons;
            qtyPc.Maximum   = qtyPc.Maximum - qtypcs;
        }
Example #17
0
        void addDescription(int id)
        {
            BunifuDropdown name   = ((BunifuDropdown)this.Controls.Find("itemNameCombo" + id, true)[0]);
            ComboBox       desc   = ((ComboBox)this.Controls.Find("itemDescCombo" + id, true)[0]);
            ComboBox       expiry = ((ComboBox)this.Controls.Find("expiry" + id, true)[0]);

            desc.Items.Clear();
            expiry.Items.Clear();
            bool exists = false;

            foreach (item i in itemsList)
            {
                if (i.Name == name.selectedValue)
                {
                    foreach (string s in desc.Items)
                    {
                        if (s == i.desc)
                        {
                            exists = true;
                            break;
                        }
                    }
                    if (exists)
                    {
                        break;
                    }
                    else
                    {
                        desc.Items.Add(i.desc);
                    }
                }
            }
            if (desc.Items.Count > 0)
            {
                desc.Text = desc.Items[0].ToString();
            }
        }
Example #18
0
        void setAmount(int id)
        {
            NumericUpDown  qtyCart    = ((NumericUpDown)this.Controls.Find("itemQtyCartTB" + id, true)[0]);
            NumericUpDown  qtyPc      = ((NumericUpDown)this.Controls.Find("itemQtyPcTB" + id, true)[0]);
            NumericUpDown  unitPrice  = ((NumericUpDown)this.Controls.Find("itemUnitPriceTB" + id, true)[0]);
            NumericUpDown  tradeOffer = ((NumericUpDown)this.Controls.Find("tradeOfferTB" + id, true)[0]);
            Label          amount     = ((Label)this.Controls.Find("totalLB" + id, true)[0]);
            BunifuDropdown name       = ((BunifuDropdown)this.Controls.Find("itemNameCombo" + id, true)[0]);
            ComboBox       desc       = ((ComboBox)this.Controls.Find("itemDescCombo" + id, true)[0]);
            ComboBox       expiry     = ((ComboBox)this.Controls.Find("expiry" + id, true)[0]);

            if (qtyCart.Value > qtyCart.Maximum)
            {
                qtyCart.Value = qtyCart.Maximum;
            }
            if (qtyPc.Value > qtyPc.Maximum)
            {
                qtyPc.Value = qtyPc.Maximum;
            }
            if (name.selectedIndex != -1 && desc.SelectedIndex != -1 && expiry.SelectedIndex != -1)
            {
                foreach (item i in orderList)
                {
                    if (i.Name == name.selectedValue && i.desc == desc.Text && i.expiry == expiry.Text)
                    {
                        i.rate       = int.Parse(unitPrice.Value.ToString());
                        i.qtypcs     = int.Parse(qtyPc.Text);
                        i.qtycart    = int.Parse(qtyCart.Text);
                        i.tradeOffer = tradeOffer.Value.ToString();
                        double total = calculateItemTotal(i);
                        amount.Text = total.ToString();
                        i.total     = double.Parse(total.ToString());
                    }
                }
            }
        }
Example #19
0
        public static bool Missedbox(List <BunifuMaterialTextbox> textBoxes, BunifuDropdown comboBox)
        {
            bool missed = false;

            foreach (var item in textBoxes)
            {
                try
                {
                    if (item.Text.Length == 0 && comboBox.selectedValue == "")
                    {
                    }
                    else if (item.Text.Length == 0)
                    {
                        missed = true;
                    }
                }
                catch (Exception)
                {
                    missed = true;
                }
            }

            return(missed);
        }
Example #20
0
 private void Register_Load(object sender, EventArgs e)
 {
     backbutton           = BackBTN;
     backbutton2          = BackBTN2;
     regpositionscombobox = RegPositionsComboBox;
 }
Example #21
0
        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);
        }
Example #22
0
        private void btnSaveEmployee_Click(object sender, EventArgs e)
        {
            string rowId = empTbl.Rows[empTbl.CurrentRow.Index].Cells[0].Value.ToString();

            bool error = false;

            foreach (Control control in tabPage1.Controls)
            {
                if (control is BunifuTextBox)
                {
                    BunifuTextBox textBox = control as BunifuTextBox;
                    if (textBox.Text == "")
                    {
                        string[] optionalFields = { "txtMiddle", "txtSss", "txtTin", "txtPhilhealth", "txtPagibig" };

                        if (optionalFields.Contains(textBox.Name))
                        {
                            error = false;
                        }
                        else
                        {
                            error = true;
                        }
                    }
                }
                else if (control is BunifuDropdown)
                {
                    BunifuDropdown jobType = control as BunifuDropdown;

                    if (jobType.SelectedIndex == -1)
                    {
                        error = true;
                    }
                }
            }

            if (error)
            {
                MessageBox.Show("Fill all required fields!", "Error");
                return;
            }

            using (SQLiteConnection conn = new SQLiteConnection(database.ConnectionString))
            {
                conn.Open();
                using (SQLiteCommand command = new SQLiteCommand())
                {
                    string query   = null;
                    string message = null;

                    if (updateInformation)
                    {
                        query = @"UPDATE EMP_TBL " +
                                "SET emp_id=@emp_id,last=@last,first=@first,middle=@middle,address=@address,dob=@dob,civil=@civil," +
                                "nationality=@nationality,sss=@sss,philhealth=@philhealth,pagibig=@pagibig,tin=@tin,email=@email," +
                                "mobile=@mobile,position=@position,class=@class,basic=@basic,allowance=@allowance WHERE id_emp_tbl=@rowid";
                        message = "Employee details updated successfully!";
                        command.Parameters.AddWithValue("@rowid", rowId);
                    }
                    else
                    {
                        query = @"INSERT INTO EMP_TBL " +
                                "(emp_id,last,first,middle,address,dob,civil,nationality,sss,philhealth,pagibig,tin,email,mobile,position,class,basic,allowance)" +
                                "VALUES " +
                                "(@emp_id,@last,@first,@middle,@address,@dob,@civil,@nationality,@sss,@philhealth,@pagibig,@tin,@email,@mobile,@position,@class,@basic,@allowance)";
                        message = "New Employee inserted!";
                    }

                    command.CommandText = query;
                    command.Connection  = conn;
                    command.Parameters.AddWithValue("@emp_id", txtEmpId.Text);
                    command.Parameters.AddWithValue("@last", txtLast.Text);
                    command.Parameters.AddWithValue("@first", txtFirst.Text);
                    command.Parameters.AddWithValue("@middle", txtMiddle.Text);
                    command.Parameters.AddWithValue("@address", txtAddress.Text);
                    command.Parameters.AddWithValue("@dob", txtDob.Value.ToString("MM-dd-yy"));
                    command.Parameters.AddWithValue("@civil", txtCivil.Text);
                    command.Parameters.AddWithValue("@nationality", txtNationality.Text);
                    command.Parameters.AddWithValue("@sss", txtSss.Text);
                    command.Parameters.AddWithValue("@philhealth", txtPhilhealth.Text);
                    command.Parameters.AddWithValue("@pagibig", txtPagibig.Text);
                    command.Parameters.AddWithValue("@tin", txtTin.Text);
                    command.Parameters.AddWithValue("@email", txtEmail.Text);
                    command.Parameters.AddWithValue("@mobile", txtMobile.Text);
                    command.Parameters.AddWithValue("@position", txtPosition.Text);
                    command.Parameters.AddWithValue("@class", txtType.GetItemText(txtType.SelectedItem));
                    command.Parameters.AddWithValue("@basic", txtBasic.Text);
                    command.Parameters.AddWithValue("@allowance", txtAllowance.Text);

                    if (command.ExecuteNonQuery() > 0)
                    {
                        MessageBox.Show(message, "Success");
                        empTbl.Rows.Clear();
                        attendanceTbl.Rows.Clear();
                        loadAttendanceTable();
                        loadDashboardTable();
                        clear();
                    }
                    else
                    {
                        MessageBox.Show("There is a problem while inserting the data. Call the Programmer to resolve this problem.", "Error");
                    }
                }
                conn.Close();
            }
        }
        public void DatPhong(TextBoxX tbhoten, BunifuDropdown ddGioiTinh, TextBoxX tbsocmt, TextBoxX tbphone, BunifuDatepicker DPNgayDat, BunifuDatepicker DPNgayTra, Label label2, Label label8, out int transfer)
        {
            transfer = 0;
            ChuanHoa ch = new ChuanHoa();

            HotelObject.KhachHangHo kh = new HotelObject.KhachHangHo();
            HotelObject.ThuePhongHo tp = new HotelObject.ThuePhongHo();
            HotelObject.PhongHo     p = new HotelObject.PhongHo();
            string day, month, year;
            string day1, month1, year1;
            string day2, month2, year2;

            ch.ChuanHoaDate(DPNgayTra.Value.ToString(), out day1, out month1, out year1);
            ch.ChuanHoaDate(DPNgayDat.Value.ToString(), out day, out month, out year);
            ch.ChuanHoaDate(DateTime.Now.ToString(), out day2, out month2, out year2);
            Connection cn = new Connection();

            if (ch.CheckTB(tbhoten.Text, tbsocmt.Text, tbphone.Text) == false)
            {
                Notification nf = new Notification("LỖI", "Thông tin phải được nhập đầy đủ.", "Mời bạn nhập lại.");
                nf.Show();
            }
            else if (ch.Check_Text_Name(tbhoten) == false)
            {
                Notification nf = new Notification("LỖI", "Tên không chứa chữ số.", "Mời bạn nhập lại.");
                nf.Show();
            }
            else if (ch.CheckDate(Int32.Parse(day2), Int32.Parse(month2), Int32.Parse(year2), Int32.Parse(day), Int32.Parse(month), Int32.Parse(year)) == false)
            {
                Notification nf = new Notification("LỖI", "Ngày đặt phòng không hợp lệ.", "Mời bạn nhập lại.");
                nf.Show();
            }
            else if (ch.CheckDate(Int32.Parse(day), Int32.Parse(month), Int32.Parse(year), Int32.Parse(day1), Int32.Parse(month1), Int32.Parse(year1)) == false)
            {
                Notification nf = new Notification("LỖI", "Ngày đặt phòng và ngày trả phòng không hợp lệ.", "Mời bạn nhập lại.");
                nf.Show();
            }

            else if (ch.Check_SoCMT(tbsocmt) == false)
            {
                Notification nf = new Notification("LỖI", "Số CMT không hợp lệ.", "Mời bạn nhập lại.");
                nf.Show();
            }
            else if (ch.Check_Phone(tbphone) == false)
            {
                Notification nf = new Notification("LỖI", "Số điện thoại không hợp lệ.", "Mời bạn nhập lại.");
                nf.Show();
            }
            else
            {
                kh.TenKhachHang = ch.CH_Name(tbhoten);
                kh.SoCMT        = ch.CH_Space(tbsocmt);
                string temp = null, temp2 = null;
                kh.MaKhachHang = cn.LayBien("select makhachhang from khachhang order by makhachhang asc", 0);
                tp.MaThue      = cn.LayBien("select mathue from thuephong order by mathue asc", 0);
                for (int i = 2; i < tp.MaThue.Length; i++)
                {
                    temp2 = temp2 + tp.MaThue[i];
                }
                tp.MaThue = "TP" + (Int32.Parse(temp2) + 1).ToString();
                p.MaPhong = cn.LayBien("select maphong from phong where tenphong='" + label2.Text + "'", 0);
                for (int i = 2; i < kh.MaKhachHang.Length; i++)
                {
                    temp = temp + kh.MaKhachHang[i];
                }

                kh.MaKhachHang = "KH" + (Int32.Parse(temp) + 1).ToString();

                cn.InsertDeleteUpdate("INSERT INTO KHACHHANG VALUES('" + kh.MaKhachHang + "',N'" + kh.TenKhachHang + "',N'" + ddGioiTinh.selectedValue + "','" + kh.SoCMT + "','" + tbphone.Text + "')");
                cn.InsertDeleteUpdate("INSERT INTO THUEPHONG VALUES('" + tp.MaThue + "','" + kh.MaKhachHang + "','" + p.MaPhong + "','" + year + month + day + "','" + year1 + month1 + day1 + "',1)");
                Notification nf = new Notification("ĐẶT PHÒNG", "Đặt phòng thành công.", "");
                nf.Show();
                transfer = 1;
            }
        }
Example #24
0
 public void LayLoaiPhong(BunifuDropdown ddtenphong, Label tenphong, Label loaiphong)
 {
     tenphong.Text  = ddtenphong.selectedValue;
     loaiphong.Text = conn.LayBien("EXEC PROC_SELECT_MALOAIPHONG N'" + tenphong.Text + "'", 0);
 }