Exemplo n.º 1
0
        private void BindDrpCustomer()
        {
            var customersSource = new CustomerRepository().GetAll().OrderBy(a => a.Name).ToList();

            var emptyCustomer = new Repository.Entity.Domain.Customer();

            emptyCustomer.Id   = -1;
            emptyCustomer.Name = "انتخاب کنید...";
            customersSource.Insert(0, emptyCustomer);
            drpCustomer.DataSource     = customersSource;
            drpCustomer.DataValueField = "Id";
            drpCustomer.DataTextField  = "Name";
            drpCustomer.DataBind();
        }
Exemplo n.º 2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(txtName.Text))
                {
                    throw new LocalException("Name is empty", "نام  را وارد نمایید");
                }

                UnitOfWork uow = new UnitOfWork();

                if (Page.RouteData.Values["Id"].ToSafeInt() == 0)
                {
                    var newCustomer = new Repository.Entity.Domain.Customer();

                    newCustomer.Code    = txtCode.Text;
                    newCustomer.Name    = txtName.Text;
                    newCustomer.Tel     = txtTel.Text;
                    newCustomer.Mobile  = txtMobile.Text;
                    newCustomer.Email   = txtEmail.Text;
                    newCustomer.Address = txtAdr.Text;

                    uow.Customers.Create(newCustomer);
                }
                else
                {
                    var repo = uow.Customers;
                    var tobeEditedCustomer = repo.GetById(Page.RouteData.Values["Id"].ToSafeInt());
                    tobeEditedCustomer.Code    = txtCode.Text;
                    tobeEditedCustomer.Name    = txtName.Text;
                    tobeEditedCustomer.Tel     = txtTel.Text;
                    tobeEditedCustomer.Mobile  = txtMobile.Text;
                    tobeEditedCustomer.Email   = txtEmail.Text;
                    tobeEditedCustomer.Address = txtAdr.Text;
                }

                uow.SaveChanges();
                lblResult.InnerText = "اطلاعات با موفقیت ذخیره شد";
                ClearControls();
            }
            catch (LocalException ex)
            {
                ((SiteMaster)Page.Master).SetGeneralMessage("خطا در دخیره سازی -" + ex.ResultMessage, MessageType.Error);
            }
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                var customers = new CustomerRepository().GetAll().OrderBy(a => a.Name).ToList();

                var emptyCustomer = new Repository.Entity.Domain.Customer();
                emptyCustomer.Id   = -1;
                emptyCustomer.Name = "انتخاب کنید...";

                customers.Insert(0, emptyCustomer);
                drpCustomer.DataSource     = customers;
                drpCustomer.DataValueField = "Id";
                drpCustomer.DataTextField  = "Name";
                drpCustomer.DataBind();

                if (Page.RouteData.Values["Type"].ToSafeString() == "In")
                {
                    List <Filter> filters = new List <Filter>();
                    filters.Add(new Filter("InOutType", OperationType.Equals, (int)InOutType.In));
                    var whereClause = ExpressionBuilder.GetExpression <InputOutputDetailHelper>(filters);

                    Session["Result"]  = new InputOutputDetailRepository().GetByFilter(whereClause);
                    h3Header.InnerText = "گزارش ورود کالا";

                    RadGridReport.MasterTableView.GetColumn("columnRInId").Visible = false;
                }
                else
                {
                    List <Filter> filters = new List <Filter>();
                    filters.Add(new Filter("InOutType", OperationType.Equals, (int)InOutType.Out));
                    var whereClause = ExpressionBuilder.GetExpression <InputOutputDetailHelper>(filters);

                    Session["Result"]  = new InputOutputDetailRepository().GetByFilter(whereClause);
                    h3Header.InnerText = "گزارش خروج کالا";
                }
            }

            BindGrid();
        }