示例#1
0
 private void LoadOrder(Repository.Entity.Domain.Order order)
 {
     drpCustomer.SelectedValue    = order.CustomerId.ToString();
     txtWorkTitle.Text            = order.WorkTitle;
     drpProductType.SelectedValue = order.ProductTypeId.ToString();
     txtGrammage.Text             = order.Grammage.ToString();
     chkIsForSent.Checked         = order.IsForSent ?? false;
     chkIsExisted.Checked         = order.IsExisted ?? false;
     txtCartonCount.Text          = order.CartonCount.ToString();
     txtCartonSize.Text           = order.CartonSize.ToString();
     txtCutSize.Text            = order.CutSize;
     txtTiraj.Text              = order.Tiraj.ToString();
     chkZincExisted.Checked     = order.ZincExisted ?? false;
     chkZincSent.Checked        = order.ZincSent ?? false;
     txtZincDesc.Text           = order.ZincDesc;
     txtColorCount.Text         = order.ColorCount.ToString();
     txtColorType.Text          = order.ColorType;
     txtMachineCount.Text       = order.MachineCount.ToString();
     txtMachineDesc.Text        = order.MachineDesc;
     chkVernyDark.Checked       = order.VernyDark ?? false;
     chkVernyClear.Checked      = order.VernyClear ?? false;
     chkUVDark.Checked          = order.UvDark ?? false;
     chkUVClear.Checked         = order.UvClear ?? false;
     chkCelefonDark.Checked     = order.CelefonDark ?? false;
     chkCelefonClear.Checked    = order.CelefonClear ?? false;
     chkLabChasb.Checked        = order.LabChasb ?? false;
     chkGhalebTigh.Checked      = order.GhalebTigh ?? false;
     chkKlisheBarjesteh.Checked = order.KlisheBarjesteh ?? false;
     chkNimTigh.Checked         = order.NimTigh ?? false;
     chkCutLine.Checked         = order.CutLine ?? false;
     txtGhalebCode.Text         = order.GhalebCode;
     txtKenareh.Text            = order.Kenareh;
     txtDescription.Text        = order.Description;
     chkIsFactored.Checked      = order.IsFactored;
 }
示例#2
0
        private void SetOrderProps(Repository.Entity.Domain.Order order)
        {
            order.CustomerId    = drpCustomer.SelectedValue.ToSafeInt();
            order.WorkTitle     = txtWorkTitle.Text;
            order.ProductTypeId = drpProductType.SelectedValue.ToSafeInt();
            order.Grammage      = txtGrammage.Text.ToSafeInt();
            order.IsForSent     = chkIsForSent.Checked;
            order.IsExisted     = chkIsExisted.Checked;
            order.CartonCount   = txtCartonCount.Text.ToSafeString();
            order.CartonSize    = txtCartonSize.Text.ToSafeString();
            order.CutSize       = txtCutSize.Text;
            order.Tiraj         = txtTiraj.Text.ToSafeInt();
            order.ZincExisted   = chkZincExisted.Checked;
            order.ZincSent      = chkZincSent.Checked;
            order.ZincDesc      = txtZincDesc.Text;
            order.ColorCount    = txtColorCount.Text.ToSafeInt();
            order.ColorType     = txtColorType.Text;
            order.MachineCount  = txtMachineCount.Text.ToSafeInt();
            order.MachineDesc   = txtMachineDesc.Text;

            order.VernyDark  = chkVernyDark.Checked;
            order.VernyClear = chkVernyClear.Checked;

            order.UvDark  = chkUVDark.Checked;
            order.UvClear = chkUVClear.Checked;

            order.CelefonDark  = chkCelefonDark.Checked;
            order.CelefonClear = chkCelefonClear.Checked;

            order.LabChasb        = chkLabChasb.Checked;
            order.GhalebTigh      = chkGhalebTigh.Checked;
            order.KlisheBarjesteh = chkKlisheBarjesteh.Checked;
            order.NimTigh         = chkNimTigh.Checked;
            order.CutLine         = chkCutLine.Checked;
            order.GhalebCode      = txtGhalebCode.Text;
            order.Kenareh         = txtKenareh.Text;
            order.Description     = txtDescription.Text;
            order.IsFactored      = chkIsFactored.Checked;
            if (radUploalCutImage.UploadedFiles.Count > 0)
            {
                var imgFile = radUploalCutImage.UploadedFiles[0];

                byte[] bytes = new byte[imgFile.ContentLength];
                imgFile.InputStream.Read(bytes, 0, (int)imgFile.ContentLength);
                order.CutImage = bytes;
            }
        }
示例#3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(drpCustomer.SelectedValue))
                {
                    throw new LocalException("Customer is empty", "مشتری  را وارد نمایید");
                }
                if (string.IsNullOrEmpty(drpProductType.SelectedValue))
                {
                    throw new LocalException("ProductType is empty", "نوع جنس را وارد نمایید");
                }

                UnitOfWork uow = new UnitOfWork();

                if (Page.RouteData.Values["Id"].ToSafeInt() == 0)
                {
                    var newOrder = new Repository.Entity.Domain.Order();
                    newOrder.OrderNo = new OrderRepository().GetMaxOrderNo() + 1;
                    SetOrderProps(newOrder);
                    uow.Orders.Create(newOrder);
                }
                else
                {
                    var repo            = uow.Orders;
                    var tobeEditedOrder = repo.GetById(Page.RouteData.Values["Id"].ToSafeInt());

                    SetOrderProps(tobeEditedOrder);
                }

                uow.SaveChanges();
                ClearControls();

                ((Main)Page.Master).SetGeneralMessage("اطلاعات با موفقیت ذخیره شد", MessageType.Success);
                ClearControls();
            }
            catch (LocalException ex)
            {
                ((Main)Page.Master).SetGeneralMessage("خطا در دخیره سازی -" + ex.ResultMessage, MessageType.Error);
            }
            catch (Exception ex)
            {
                ((Main)Page.Master).SetGeneralMessage("خطا در دخیره سازی -" + ex.Message, MessageType.Error);
            }
        }