예제 #1
0
        public UnitCostFormUC(System.Web.UI.WebControls.FormViewMode view_mode_ = System.Web.UI.WebControls.FormViewMode.Insert, long?id_ = null)
        {
            view_mode = view_mode_;
            edit_id   = id_;

            InitializeComponent();
        }
예제 #2
0
        private void UpdatePurchase(System.Web.UI.WebControls.FormViewMode view_mode)
        {
            long amount;

            if (long.TryParse(fldAmount.Text_GetValue(), out amount))
            {
                long amount_left = amount;
                if (buyerGridLastRow.Rows.Count == 1)
                {
                    amount_left = amount - (long)buyerGridLastRow[nameof(Purchase.amount), 0].Value;
                }
                long id = 0;
                if (view_mode == System.Web.UI.WebControls.FormViewMode.Edit)
                {
                    id = long.Parse(dataGridView1.SelectedRows[0].Cells["id"].Value.ToString());
                    if (id == 0)
                    {
                        Constants.form_loader_loading.Warn(Constants.MessageText.PendingChangesMes("سرمایه گذار"));
                        return;
                    }
                }
                if (amount_left > 0 || view_mode == System.Web.UI.WebControls.FormViewMode.Edit)
                {
                    var form   = new FormLoader <Purchase>(new PurchaseForm(amount, amount_left, view_mode, id));
                    var dialog = form.ShowDialog();
                    if (dialog == DialogResult.OK)
                    {
                        Purchase purchase = form.EntityObject;
                        if (view_mode == System.Web.UI.WebControls.FormViewMode.Insert)
                        {
                            dataGridView1.AddEntity(purchase);
                        }
                        else if (view_mode == System.Web.UI.WebControls.FormViewMode.Edit)
                        {
                            dataGridView1.RemoveEntity <Purchase>();
                            dataGridView1.AddEntity(purchase);
                        }
                    }
                }
                else
                {
                    Constants.form_loader_loading.Warn(Constants.MessageText.RestrictionViolationMes("مبلغ"));
                }
            }
            else
            {
                Constants.form_loader_loading.Warn(Constants.MessageText.RequiredFieldErrorMes("مبلغ"));
            }
        }