예제 #1
0
        private void SaveBtn_Click(object sender, EventArgs e)
        {
            try
            {
                var phoneRegEx = new Regex("^(\\+380|0)([0-9]{9})$");
                if (!phoneRegEx.IsMatch(PhoneTB.Text))
                {
                    MessageBox.Show("Невіроно введений номер телефону, номер поивнен бути у форматі +380*********");
                    return;
                }
                else
                {
                    _person.Phone = PhoneTB.Text;
                }
                try
                {
                    MailAddress m = new MailAddress(EmailTB.Text);
                    _person.Email = EmailTB.Text;
                }
                catch (FormatException)
                {
                    MessageBox.Show("Перевірте коректність введеного Email");
                    return;
                }

                _person.Name    = NameTB.Text;
                _person.Surname = SurnameTB.Text;
                _person.Address = AddressTB.Text;
                try
                {
                    _person.Birthday = DateTime.Parse(BirthdayTB.Text);
                }
                catch (Exception)
                {
                    MessageBox.Show("Перевірте правильність введеня дати");
                    return;
                }
                dbContext.Entry(_person).State = System.Data.Entity.EntityState.Modified;
                dbContext.SaveChanges();
            }
            catch (Exception) {
                MessageBox.Show("Сталася помилка при збереженні");
            } finally
            {
                NameTB.ReadOnly     = true;
                SurnameTB.ReadOnly  = true;
                AddressTB.ReadOnly  = true;
                BirthdayTB.ReadOnly = true;
                PhoneTB.ReadOnly    = true;
                EmailTB.ReadOnly    = true;

                SaveBtn.Hide();
                EditBtn.Show();

                MessageBox.Show("Дані успішно збережені");
            }
        }
예제 #2
0
        private void editBtnProduct_Click(object sender, EventArgs e)
        {
            if (dgv_SalesBill.SelectedRows.Count == 0)
            {
                MessageBoxIcon.Warning.ToString();
                MessageBox.Show("يجب ان تختار منتج من المنتجات");
            }
            else
            {
                AddProPanel.Show();
                Btn_SaveProduct.Hide();
                EditBtn.Show();
                var P_id = int.Parse(dgv_SalesBill.SelectedRows[0].Cells[6].Value.ToString());

                Como_productCategoryUpdate.DataSource    = store.categories.ToList();
                Como_productCategoryUpdate.DisplayMember = "CategoryName";
                Como_productCategoryUpdate.ValueMember   = "ID";

                //////suplier
                Como_productBuySupplierUp.DataSource    = store.suppliers.ToList();
                Como_productBuySupplierUp.DisplayMember = "Name";
                Como_productBuySupplierUp.ValueMember   = "ID";
                ////unt
                Como_productUnitUpdate.DataSource    = store.ProductUnits.ToList();
                Como_productUnitUpdate.DisplayMember = "Name";
                Como_productUnitUpdate.ValueMember   = "ID";

                var query = store.products.FirstOrDefault(d => d.ID == P_id);


                Txt_ProductNameUp.Text                  = query.ProductName;
                numericDiscountProUp.Text               = query.Discount.ToString();
                numericIncomingPriceProUp.Text          = query.IncomePrice.ToString();
                numericIndvidualPriceProUp.Text         = query.Price_individual.ToString();
                numericQuantityProUp.Text               = query.quantityPerProducts.ToString();
                numericQuantityPackageProUp.Value       = query.quantityPerGroup;
                Como_productCategoryUpdate.SelectedText = query.categories.CategoryName.ToString();
                Como_productBuySupplierUp.SelectedText  = query.Supplier.Name.ToString();
                Como_productUnitUpdate.SelectedText     = query.ProductUnit.Name.ToString();
            }
        }
예제 #3
0
        public void ShowCmdWindow(string cmd, int LscId, string LscName, string LscIP, int LscPort, string LscUID, string LscPwd, int BeatInterval, int BeatDelay, string DBServer, int DBPort, string DBName, string DBUID, string DBPwd, string HisDBServer, int HisDBPort, string HisDBName, string HisDBUID, string HisDBPwd, bool Enabled)
        {
            switch (cmd)
            {
            case "Edit":
                LSCWindow.Icon      = Icon.ChartOrganisation;
                LSCWindow.Title     = "编辑信息";
                LSCIDField.Disabled = true;
                LSCStatusBar.ClearStatus();
                SaveBtn.Hide();
                EditBtn.Show();
                LSCIDField.Number        = LscId;
                LSCNameField.Text        = LscName;
                LSCIPField.Text          = LscIP;
                LSCPortField.Number      = LscPort;
                LSCUIDField.Text         = LscUID;
                LSCPwdField.Text         = LscPwd;
                BeatIntervalField.Number = BeatInterval;
                BeatDelayField.Number    = BeatDelay;
                DBIPField.Text           = DBServer;
                DBPortField.Number       = DBPort;
                DBNameField.Text         = DBName;
                DBUIDField.Text          = DBUID;
                DBPwdField.Text          = DBPwd;
                HisDBIPField.Text        = HisDBServer;
                HisDBPortField.Number    = HisDBPort;
                HisDBNameField.Text      = HisDBName;
                HisDBUIDField.Text       = HisDBUID;
                HisDBPwdField.Text       = HisDBPwd;
                EnabledCheckbox.Checked  = Enabled;
                LSCWindow.Show();
                break;

            case "Del":
                X.Msg.Confirm("确认对话框", "本操作将删除与Lsc有关的所有数据!您确定要删除吗?", new MessageBoxButtonsConfig {
                    Yes = new MessageBoxButtonConfig {
                        Handler = String.Format(@"
                            X.LSCManager.DelLsc({0},{{
                            success: function(result) {{
                                LSCPagingToolbar.doRefresh();
                            }},
                            eventMask: {{
                                showMask: true,
                                target: 'customtarget',
                                msg: '正在删除中...',
                                customTarget: LSCPanel.body.up('div')
                            }}}});", LscId),
                        Text    = "确定"
                    },
                    No = new MessageBoxButtonConfig {
                        Text = "取消"
                    }
                }).Show();
                break;

            case "Add":
                LSCWindow.Icon          = Icon.ChartOrganisationAdd;
                LSCWindow.Title         = "新增信息";
                EnabledCheckbox.Checked = false;
                LSCIDField.Disabled     = false;
                LSCStatusBar.ClearStatus();
                SaveBtn.Show();
                EditBtn.Hide();
                LSCIDField.Clear();
                LSCNameField.Clear();
                LSCIPField.Clear();
                LSCPortField.Number = LscPort;
                LSCUIDField.Clear();
                LSCPwdField.Clear();
                BeatIntervalField.Number = BeatInterval;
                BeatDelayField.Number    = BeatDelay;
                DBIPField.Clear();
                DBPortField.Number = DBPort;
                DBNameField.Clear();
                DBUIDField.Clear();
                DBPwdField.Clear();
                HisDBIPField.Clear();
                HisDBPortField.Number = HisDBPort;
                HisDBNameField.Clear();
                HisDBUIDField.Clear();
                HisDBPwdField.Clear();
                EnabledCheckbox.Checked = Enabled;
                LSCWindow.Show();
                break;

            case "Sync":
                SyncWindow.Icon   = Icon.DatabaseRefresh;
                SyncWindow.Title  = String.Format("数据同步[{0}]", LscName);
                STRadio.Checked   = true;
                SyncWindowHF.Text = LscId.ToString();
                SyncWindow.Show();
                break;

            default:
                break;
            }
        }