示例#1
0
        private void btn_Click(object sender, EventArgs e)
        {
            switch (show)
            {
            case "store":
            {
                ucAddProdoctStore addStore = new ucAddProdoctStore();
                addStore.panelProdoct.Visible = false;
                addStore.panelStore.Visible   = true;
                addStore.panelStore.Dock      = DockStyle.Fill;
                addStore.Size = new System.Drawing.Size(280, 200);
                pop           = new Popup(addStore);
                pop.Closed   += popup_Closed;
                pop.Show(this);
                break;
            }

            case "prodoct":
            {
                ucAddProdoctStore addProdoct = new ucAddProdoctStore();
                addProdoct.panelProdoct.Visible = true;
                addProdoct.panelStore.Visible   = false;
                addProdoct.panelProdoct.Dock    = DockStyle.Fill;
                addProdoct.Size = new System.Drawing.Size(280, 210);
                pop             = new Popup(addProdoct);
                pop.Closed     += popup_Closed;
                pop.Show(this);
                break;
            }

            case "editProdoct":
            {
                ucAddProdoctStore EditPtodoct = new ucAddProdoctStore();
                EditPtodoct.panelProdoct.Visible = true;
                EditPtodoct.panelStore.Visible   = false;
                EditPtodoct.panelProdoct.Dock    = DockStyle.Fill;
                EditPtodoct.Size    = new System.Drawing.Size(280, 210);
                EditPtodoct.id      = id;
                EditPtodoct.name    = name;
                EditPtodoct.code    = code;
                EditPtodoct.unit    = unit;
                EditPtodoct.detail  = detail;
                EditPtodoct.barcode = barcode;
                EditPtodoct.rfid    = rfid;
                pop         = new Popup(EditPtodoct);
                pop.Closed += popup_Closed;
                pop.Show(this);
                break;
            }
            }
        }
示例#2
0
        private void Add_Unit()
        {
            using (var context = new Service.StimulsoftEntities())
            {
                if (context.Unit.Count() > 0)
                {
                    bool existUnit = context.Unit.Where(c => c.Name == txtUnitName.Text).Any();
                    if (existUnit)
                    {
                        MessageBox.Show("واحدی با این نام وجود دارد", "واحد", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        Service.Unit newUnit = new Service.Unit();
                        newUnit.Name = txtUnitName.Text;
                        context.Unit.Add(newUnit);
                        context.SaveChanges();
                        //MessageBox.Show("واحد ثبت شد", "ثبت", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        txtUnitName.Text = "";
                        txtUnitName.Focus();
                    }
                }
                else
                {
                    Service.Unit newUnit = new Service.Unit();
                    newUnit.Name = txtUnitName.Text;
                    context.Unit.Add(newUnit);
                    context.SaveChanges();
                    //MessageBox.Show("واحد ثبت شد", "ثبت", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtUnitName.Text = "";
                    txtUnitName.Focus();
                }
            }
            ucAddProdoctStore ucadd = new ucAddProdoctStore();

            ucadd.Refresh_comUnit();
        }