コード例 #1
0
ファイル: Frm_Stores.cs プロジェクト: MMonsef/Xtra_Sales
        public override void Save()
        {
            if (string.IsNullOrEmpty(Txt_name.Text))
            {
                Txt_name.ErrorText = "يرجى إدخال اسم المخزن  !";
                return;
            }
            else
            {
                var db = new SalesDataContext();

                if (Store.id == 0)
                {
                    Action = "Insert";
                    db.stores.InsertOnSubmit(Store);
                }
                else
                {
                    Action = "Update";
                    db.stores.Attach(Store);
                }
                SetData();
                db.SubmitChanges();
                base.Save();
                Txt_name.Text = string.Empty;
                Txt_name.Focus();
            }
        }
コード例 #2
0
        public override void Save()
        {
            if (string.IsNullOrEmpty(Txt_name.Text))
            {
                Txt_name.ErrorText = "يرجى إدخال اسم الخزنة  !";
                return;
            }
            else
            {
                var      db = new SalesDataContext();
                accounts Account;

                if (Treasury.id == 0)
                {
                    Action  = "Insert";
                    Account = new accounts();
                    db.treasurys.InsertOnSubmit(Treasury);
                    db.accounts.InsertOnSubmit(Account);
                }
                else
                {
                    Action = "Update";
                    db.treasurys.Attach(Treasury);
                    Account = db.accounts.Single(S => S.id == Treasury.account_id);
                }
                SetData();
                Account.name = Treasury.name;
                db.SubmitChanges();
                Treasury.account_id = Account.id;
                db.SubmitChanges();
                Txt_name.Text = string.Empty;
                Txt_name.Focus();
                base.Save();
            }
        }