Beispiel #1
0
 private void btnLeft_Click(object sender, EventArgs e)
 {
     foreach (Control ctr in flpAllitems.Controls)
     {
         if (ctr.BackColor == Color.FromArgb(0, 102, 204))
         {
             UCMenuAdd     ucMenuGet = (UCMenuAdd)ctr;
             ModifireModel itemLeft  = (ModifireModel)(ctr.Tag);
             ModifireModel itemRight = new ModifireModel();
             itemRight.ModifireName = itemLeft.ModifireName;
             itemRight.ModifireID   = itemLeft.ModifireID;
             listItem.Add(itemRight);
             var index = -1;
             for (int i = 0; i < listAllItem.Count; i++)
             {
                 if (listAllItem[i].ModifireID == itemRight.ModifireID)
                 {
                     index = i;
                 }
             }
             if (index > -1)
             {
                 listAllItem.RemoveAt(index);
             }
         }
     }
     LoadThisGroupItems();
     LoadAllItem();
 }
Beispiel #2
0
        public int UpdatePosition(ModifireModel item)
        {
            int    resut = 0;
            string sql   = "UPDATE MODIFIRE SET Position='" + item.Position + "' WHERE ModifireID='" + item.ModifireID + "'";

            resut = _context.Database.ExecuteSqlCommand(sql);
            return(resut);
        }
Beispiel #3
0
        private void btnUp_Click(object sender, EventArgs e)
        {
            if (indexOfControl > 0)
            {
                ModifireModel item = (ModifireModel)(ucAddMenu.Tag);
                flpThisgroupitems.Controls.SetChildIndex(ucAddMenu, indexOfControl - 1);

                indexOfControl = flpThisgroupitems.Controls.IndexOf(ucAddMenu);
            }
        }
Beispiel #4
0
        private void btnDown_Click(object sender, EventArgs e)
        {
            int total = flpThisgroupitems.Controls.Count;

            if (indexOfControl > 0 && indexOfControl < total)
            {
                ModifireModel item = (ModifireModel)(ucAddMenu.Tag);
                flpThisgroupitems.Controls.SetChildIndex(ucAddMenu, indexOfControl + 1);

                indexOfControl = flpThisgroupitems.Controls.IndexOf(ucAddMenu);
            }
        }
Beispiel #5
0
 private void btnAllRight_Click(object sender, EventArgs e)
 {
     foreach (var data in listItem)
     {
         ModifireModel itemLeft = new ModifireModel();
         itemLeft.ModifireID   = data.ModifireID;
         itemLeft.ModifireName = data.ModifireName;
         listAllItem.Add(itemLeft);
     }
     listItem = new List <ModifireModel>();
     LoadThisGroupItems();
     LoadAllItem();
 }
Beispiel #6
0
 private void UpdatePosition()
 {
     for (int i = 0; i < flpThisgroupitems.Controls.Count; i++)
     {
         ModifireModel item = (ModifireModel)(flpThisgroupitems.Controls[i].Tag);
         item.Position = flpThisgroupitems.Controls.IndexOf(flpThisgroupitems.Controls[i]);
         lstPosition.Add(item);
     }
     for (int j = 0; j < lstPosition.Count; j++)
     {
         ModifireService.UpdatePosition(lstPosition[j]);
     }
 }
Beispiel #7
0
        void ucModifierItem_Click(object sender, EventArgs e)
        {
            UCModifierItem ucModifierItem = (UCModifierItem)sender;
            ModifireModel  dataModifire   = (ModifireModel)(ucModifierItem.Tag);

            flag = 4;
            foreach (Control ctr in flpMenuList.Controls)
            {
                if (ctr.BackColor == Color.FromArgb(0, 153, 51))
                {
                    ctr.BackColor = Color.FromArgb(255, 255, 255);
                    ctr.ForeColor = Color.FromArgb(51, 51, 51);
                }
            }
            ucModifierItem.BackColor = Color.FromArgb(0, 153, 51);
            ucModifierItem.ForeColor = Color.FromArgb(255, 255, 255);
            addModifierItemDetail(dataModifire);
        }
Beispiel #8
0
        public int Delete(ModifireModel data)
        {
            var checkdata = _context.MODIFIREs.Find(data.ModifireID);

            if (checkdata != null)
            {
                checkdata.Status                = 0;
                checkdata.UpdateBy              = data.UpdateBy ?? 0;
                checkdata.UpdateDate            = DateTime.Now;
                _context.Entry(checkdata).State = EntityState.Modified;
                _context.SaveChanges();
                return(1);
            }
            else
            {
                return(0);
            }
        }
Beispiel #9
0
        private void addModifierItemDetail(ModifireModel dataModifire)
        {
            //pnDetail.Controls.Clear();

            if (dataModifire.ModifireID > 0)
            {
                UCModifier ucModifier = new UCModifier();
                if (pnDetail.Controls.Count > 0)
                {
                    ucModifier = (UCModifier)pnDetail.Controls[0];
                }
                else
                {
                    ucModifier.Dock = DockStyle.Fill;
                    pnDetail.Controls.Add(ucModifier);
                }
                ucModifier.Dock = DockStyle.Fill;
                ucModifier.lblModifierName.Text = dataModifire.ModifireName;
                ucModifier.txtModifierName.Text = dataModifire.ModifireName;
                if (dataModifire.CurrentPrice > 0)
                {
                    ucModifier.txtModifierPrice.Text = money.Format2(dataModifire.CurrentPrice.ToString());
                }
                else
                {
                    ucModifier.txtModifierPrice.Text = "0";
                }
                ucModifier.btnSave.Tag      = dataModifire;
                ucModifier.btnSave.Click   += ucModifier_btnSave_Click;
                ucModifier.btnRemove.Tag    = dataModifire;
                ucModifier.btnRemove.Click += ucModifier_btnRemove_Click;
                pnDetail.Controls.Add(ucModifier);
                ucModifier = (UCModifier)pnDetail.Controls[0];
                ucModifier.cbColor.SelectedItem = dataModifire.Color;
            }
            else
            {
                pnDetail.Controls.Clear();
            }
        }
Beispiel #10
0
        private void ucModifier_btnRemove_Click(object sender, EventArgs e)
        {
            frmConfirm frmcon = new frmConfirm("Warning", "Do you want remove this modifier ?");

            frmcon.ShowDialog();
            if (frmcon.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                Button        modifier     = (Button)sender;
                ModifireModel dataModifier = (ModifireModel)(modifier.Tag);
                var           result       = ModifireService.Delete(dataModifier);
                if (result == 1)
                {
                    addModifier("Modifier List", 4, this.CurrentPage);
                    pnDetail.Controls.Clear();
                    frmMessager frm = new frmMessager("Messenger", "Delete modifire success.");
                    frmOpacity.ShowDialog(this, frm);
                }
                else
                {
                    frmMessager frm = new frmMessager("Messenger", "Delete modifire fail.");
                    frmOpacity.ShowDialog(this, frm);
                }
            }
        }
Beispiel #11
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            frmConfirm frmcon = new frmConfirm("Messenger", "Do you want edit info price of product ?");

            frmcon.ShowDialog();
            if (frmcon.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                Button         btn           = (Button)sender;
                PriceListModel dataPriceList = (PriceListModel)(btn.Tag);
                var            txtPrice      = txtProductPrice.Text;
                var            txtName       = txtProductName.Text;
                var            comboColor    = cbColor.Text;
                string         message_error = "";

                if (txtPrice == "")
                {
                    message_error = "Price is not empty";
                }
                if (txtName == "")
                {
                    message_error = "Name is not empty";
                }

                if (message_error == "")
                {
                    dataPriceList.CurrentPrice = Convert.ToDouble(txtPrice) * 1000;
                    dataPriceList.NameDesc     = txtName;
                    if (comboColor == "")
                    {
                        dataPriceList.Color = dataPriceList.Color;
                    }
                    else
                    {
                        dataPriceList.Color = comboColor;
                    }
                    var result = 0;
                    if (dataPriceList.Type == "MODIFIRE")
                    {
                        ModifireModel modifire = new ModifireModel();
                        modifire.ModifireID   = dataPriceList.ID;
                        modifire.CurrentPrice = dataPriceList.CurrentPrice;
                        modifire.ModifireName = dataPriceList.NameDesc;
                        modifire.Color        = dataPriceList.Color;
                        result = ModifireService.Created(modifire);
                    }
                    else
                    {
                        ProductionModel product = new ProductionModel();
                        product.ProductID       = dataPriceList.ID;
                        product.CurrentPrice    = dataPriceList.CurrentPrice;
                        product.ProductNameDesc = dataPriceList.NameDesc;
                        product.ProductNameSort = dataPriceList.NameSort;
                        product.Color           = dataPriceList.Color;
                        result = ProductService.Created(product);
                    }
                    if (result == 1)
                    {
                        this.DialogResult = System.Windows.Forms.DialogResult.OK;
                        this.Close();
                    }
                    else
                    {
                        frmMessager frmMessager = new frmMessager("Edit Product Price", "Error");
                        frmOpacity.ShowDialog(this, frmMessager);
                        this.Close();
                    }
                }
                else
                {
                    frmMessager frmMessager = new frmMessager("Edit Product Price", message_error);
                    frmOpacity.ShowDialog(this, frmMessager);
                }
            }
        }
Beispiel #12
0
        private void ucModifier_btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                Button        modifier      = (Button)sender;
                ModifireModel dataModifier  = (ModifireModel)(modifier.Tag);
                string        message_error = "";
                var           ucModifier    = (UCModifier)pnDetail.Controls[0];
                var           modifierName  = ucModifier.txtModifierName.Text;
                var           modifierColor = ucModifier.cbColor.Text;
                var           modifierPrice = Convert.ToDouble(ucModifier.txtModifierPrice.Text) * 1000;

                if (dataModifier == null)
                {
                    dataModifier = new ModifireModel();
                }

                if (modifierName == "")
                {
                    message_error += "Modifire name isn't empty.";
                }
                if (modifierColor == "")
                {
                    message_error += "Modifire Color isn't empty";
                }
                if (modifierPrice.ToString() == "")
                {
                    message_error += "Modifre price isn't empty";
                }
                if (message_error == "")
                {
                    dataModifier.ModifireName = modifierName;
                    dataModifier.Color        = modifierColor;
                    dataModifier.CurrentPrice = (modifierPrice);
                    var result  = ModifireService.Created(dataModifier);
                    var message = "";
                    if (result == 1)
                    {
                        addModifier("Modifier List", 4, this.CurrentPage);
                        pnDetail.Controls.Clear();
                        message = "Save modifier Successful";
                    }
                    else
                    {
                        if (result == -1)
                        {
                            message = "Modifier name already exist. Please change modifire name.";
                        }
                        else
                        {
                            message = "Save modifier fail";
                        }
                    }
                    frmMessager frm = new frmMessager("Messenger", message);
                    frmOpacity.ShowDialog(this, frm);
                }
                else
                {
                    frmMessager frm = new frmMessager("Messenger", message_error);
                    frmOpacity.ShowDialog(this, frm);
                }
            }
            catch (Exception ex)
            {
                SystemLog.LogPOS.WriteLog("frmMenuSetting::::::::::::::::::::::ucModifier_btnSave_Click::::::::::::::::" + ex.Message);
            }
        }
Beispiel #13
0
        public int Created(ModifireModel data)
        {
            try
            {
                if (data.ModifireID == 0)
                {
                    var checkdata = _context.MODIFIREs.Where(x => x.ModifireName == data.ModifireName).ToList();
                    if (checkdata.Count() > 0)
                    {
                        return(-1);
                    }

                    var new_data = new MODIFIRE();
                    new_data.ModifireName = data.ModifireName;
                    new_data.Color        = data.Color ?? "";
                    new_data.Status       = 1;
                    new_data.CreateBy     = data.CreateBy ?? 0;
                    new_data.CreateDate   = DateTime.Now;
                    new_data.UpdateBy     = data.UpdateBy ?? 0;
                    new_data.UpdateDate   = DateTime.Now;
                    new_data.Note         = data.Note ?? "";

                    _context.Entry(new_data).State = EntityState.Added;
                    _context.SaveChanges();
                    var modifire_price = new MODIFIRE_PRICE();
                    modifire_price.ModifireID   = new_data.ModifireID;
                    modifire_price.CurrentPrice = data.CurrentPrice;
                    modifire_price.CreateBy     = data.CreateBy ?? 0;
                    modifire_price.CreateDate   = DateTime.Now;
                    modifire_price.UpdateBy     = data.UpdateBy ?? 0;
                    modifire_price.UpdateDate   = DateTime.Now;
                    modifire_price.Note         = data.Note ?? "";
                    var result = CreatedModifirePrice(modifire_price);
                    return(result);
                }
                else
                {
                    var checkdata = _context.MODIFIREs.Where(x => x.ModifireName == data.ModifireName && x.ModifireID != data.ModifireID).ToList();
                    if (checkdata.Count() > 0)
                    {
                        return(-1);
                    }
                    var old_data = _context.MODIFIREs.Find(data.ModifireID);
                    if (old_data != null)
                    {
                        old_data.ModifireName = data.ModifireName;
                        old_data.Color        = data.Color ?? "";
                        old_data.Status       = 1;
                        old_data.UpdateBy     = data.UpdateBy ?? 0;
                        old_data.UpdateDate   = DateTime.Now;
                        old_data.Note         = data.Note ?? "";

                        _context.Entry(old_data).State = EntityState.Modified;
                        _context.SaveChanges();
                        var modifire_price = new MODIFIRE_PRICE();
                        modifire_price.ModifireID   = data.ModifireID;
                        modifire_price.CurrentPrice = data.CurrentPrice;
                        modifire_price.CreateBy     = data.CreateBy ?? 0;
                        modifire_price.CreateDate   = DateTime.Now;
                        modifire_price.UpdateBy     = data.UpdateBy ?? 0;
                        modifire_price.UpdateDate   = DateTime.Now;
                        modifire_price.Note         = data.Note ?? "";
                        var result = CreatedModifirePrice(modifire_price);
                        return(result);
                    }
                    return(0);
                }
            }
            catch (Exception)
            {
                return(0);
            }
        }