Ejemplo n.º 1
0
 partial void DeleteGold(Gold instance);
Ejemplo n.º 2
0
 partial void InsertGold(Gold instance);
Ejemplo n.º 3
0
 partial void UpdateGold(Gold instance);
Ejemplo n.º 4
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string uid = (sender as Button).Uid;
            SuccessMessgage.Visibility = System.Windows.Visibility.Collapsed;
            saveButton.Visibility = System.Windows.Visibility.Visible;

            if (dispathTimer != null) {
                dispathTimer.Stop();
                dispathTimer = null;
            }

            if (uid == "rowEdit") {
                pawnguardDb = new PawnGuardDBDataContext();
                toEditGold = pawnguardDb.Golds
                             .SingleOrDefault<Gold>(gld => gld.Id.ToString() == (sender as Button).Content.ToString());

                dgGolds.SelectedItem = toEditGold;
                VisualStateManager.GoToElementState(this.LayoutRoot, "ShowState", true);
            }

            if (uid == "closePanel") {
                VisualStateManager.GoToElementState(this.LayoutRoot, "HideState", true);
                FillGrid();
                page_Loaded(sender, e);
            }

            //if (uid == "save") {
            //    if (toEditGold == null) {

            //        if (!IsValid())
            //            return;

            //        pawnguardDb = new PawnGuardDBDataContext();
            //        bool exist = pawnguardDb.ItemCategories.AsEnumerable()
            //                     .Where(itm => itm.main.ToLower() == txtCategory.Text.ToLower() ||
            //                                   itm.option1.ToLower() == txtOption1.Text.ToLower() ||
            //                                   itm.option2.ToLower() == txtOption2.Text.ToLower())
            //                     .Any();

            //        if (exist) {
            //            categoryError.Visibility = System.Windows.Visibility.Visible;
            //            errorMsgCategory.Text = MSG_EXIST;
            //            return;
            //        }

            //        decimal price = 0;
            //        decimal.TryParse(txtPrice.Text, out price);
            //        pawnguardDb.ItemCategories.InsertOnSubmit(new ItemCategory() {
            //            parentId = AppData.parentId,
            //            code = txtCode.Text,
            //            main = txtCategory.Text,
            //            option1 = txtOption1.Text,
            //            option2 = txtOption2.Text,
            //            price = price,
            //            createdAt = DateTime.Now,
            //            updatedAt = DateTime.Now
            //        });
            //    } else {
            //        if (!IsValid())
            //            return;

            //        string editEmail = toEditGold.main;
            //        string editoption1 = toEditGold.option1;
            //        string editoption2 = toEditGold.option2;
            //        if (!editEmail.Equals(txtCategory.Text, StringComparison.InvariantCultureIgnoreCase) &&
            //            !editoption1.Equals(txtOption1.Text, StringComparison.InvariantCultureIgnoreCase) &&
            //            !editoption2.Equals(txtOption2.Text, StringComparison.InvariantCultureIgnoreCase)) {

            //            bool exist = pawnguardDb.ItemCategories.AsEnumerable()
            //                    .Where(itm => itm.main.ToLower() == txtCategory.Text.ToLower() ||
            //                                    itm.option1.ToLower() == txtOption1.Text.ToLower() ||
            //                                    itm.option2.ToLower() == txtOption2.Text.ToLower())
            //                    .Any();

            //            if (exist) {
            //                categoryError.Visibility = System.Windows.Visibility.Visible;
            //                errorMsgCategory.Text = MSG_EXIST;
            //                return;
            //            }
            //        }

            //        decimal price = 0;
            //        decimal.TryParse(txtPrice.Text, out price);
            //        toEditGold.parentId = AppData.parentId;
            //        toEditGold.code = txtCode.Text;
            //        toEditGold.main = txtCategory.Text;
            //        toEditGold.option1 = txtOption1.Text;
            //        toEditGold.option2 = txtOption2.Text;
            //        toEditGold.price = price;
            //        toEditGold.updatedAt = DateTime.Now;
            //    }

            //    try {
            //        pawnguardDb.SubmitChanges();
            //        saveButton.Visibility = System.Windows.Visibility.Collapsed;

            //        dispathTimer = new DispatcherTimer();
            //        dispathTimer.Interval = new TimeSpan(0, 0, 1);
            //        dispathTimer.Start();

            //        int time = 3;
            //        SuccessMessgage.Visibility = System.Windows.Visibility.Visible;
            //        dispathTimer.Tick += delegate(object s, EventArgs ea) {
            //            if (time >= 0)
            //                runTime.Text = time + " sec.";
            //            else {
            //                dispathTimer.Stop();
            //                SuccessMessgage.Visibility = System.Windows.Visibility.Collapsed;
            //                VisualStateManager.GoToElementState(this.LayoutRoot, "HideState", true);
            //                runTime.Text = "3 sec.";

            //                FillGrid();
            //                page_Loaded(sender, e);
            //            }
            //            time--;
            //        };
            //    } catch (Exception) {
            //    }
            //}
        }