Exemplo n.º 1
0
        private async Task SetProductsAsync()
        {
            try
            {
                var list = await ProductBussines.GetAllAsync();

                fPanel.AutoScroll = true;
                for (var i = fPanel.Controls.Count - 1; i >= 0; i--)
                {
                    fPanel.Controls[i].Dispose();
                }
                foreach (var item in list)
                {
                    var btn = new ButtonX();
                    Controls.Add(btn);
                    btn.Size       = new Size(190, 56);
                    btn.Name       = item.Guid.ToString();
                    btn.Cursor     = Cursors.Hand;
                    btn.Text       = $"{item.Name} \r\n ({item.Price:N0})";
                    btn.ColorTable = eButtonColor.Flat;
                    btn.BackColor  = Color.DarkSlateGray;
                    btn.TextColor  = Color.White;
                    btn.Click     += Btn_Click;
                    fPanel.Controls.Add(btn);
                }
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
        }
Exemplo n.º 2
0
 private void btnFinish_Click(object sender, EventArgs e)
 {
     try
     {
         PrdList = new List <ProductBussines>();
         for (var i = 0; i < DGrid.RowCount; i++)
         {
             if (!DGrid[dgChecked.Index, i].Value.ToString().ParseToBoolean())
             {
                 continue;
             }
             var guid = (Guid)DGrid[dgGuid.Index, i].Value;
             var prd  = ProductBussines.Get(guid);
             if (prd == null)
             {
                 continue;
             }
             PrdList.Add(prd);
         }
         DialogResult = DialogResult.OK;
         Close();
     }
     catch (Exception ex)
     {
         WebErrorLog.ErrorInstence.StartErrorLog(ex);
     }
 }
Exemplo n.º 3
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            var res = new ReturnedSaveFuncInfo();

            res.AddReturnedValue(CheckValidation());
            if (res.HasError)
            {
                Toast.MakeText(this, res.ErrorMessage, ToastLength.Short).Show();
                return(base.OnOptionsItemSelected(item));
            }

            if (prd == null)
            {
                prd = new ProductBussines()
                {
                    Guid     = Guid.NewGuid(),
                    Modified = DateTime.Now,
                    Status   = true
                };
            }

            prd.Name       = txtName.Text;
            prd.Code       = txtCode.Text;
            prd.Price      = txtPrice.Text.ParseToDecimal();
            prd.BckUpPrice = txtBackUp.Text.ParseToDecimal();
            ProductBussines.Save(prd);
            Finish();
            return(base.OnOptionsItemSelected(item));
        }
Exemplo n.º 4
0
 private async Task <string> NextCodeAsync()
 {
     try
     {
         return(await ProductBussines.NextCodeAsync());
     }
     catch (Exception ex)
     {
         WebErrorLog.ErrorInstence.StartErrorLog(ex);
         return("");
     }
 }
Exemplo n.º 5
0
        private void Btn_Click(object sender, EventArgs e)
        {
            try
            {
                var guid = Guid.Parse(((ButtonX)sender).Name);

                if (_cls.DetList == null)
                {
                    _cls.DetList = new List <OrderDetailBussines>();
                }

                var _prd = _cls.DetList.FirstOrDefault(q => q.PrdGuid == guid);

                if (_prd != null)
                {
                    _cls.DetList.Remove(_prd);
                    _prd.Count++;
                    _prd.Total = _prd.Price * _prd.Count;
                    _cls.DetList.Add(_prd);
                    UpdateDets();
                    return;
                }

                var prd = ProductBussines.Get(guid);
                if (prd == null)
                {
                    return;
                }
                if (prd.Price <= 0)
                {
                    return;
                }

                var det = new OrderDetailBussines()
                {
                    Guid     = Guid.NewGuid(),
                    Modified = DateTime.Now,
                    Status   = true,
                    PrdGuid  = prd.Guid,
                    Price    = prd.Price,
                    Total    = prd.Price,
                    Discount = 0,
                    Count    = 1
                };
                _cls.DetList.Add(det);

                UpdateDets();
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
        }
Exemplo n.º 6
0
 private async Task LoadProducts(string search = null)
 {
     try
     {
         var liat = await ProductBussines.GetAllAsync(search);
         ProductBindingSource.DataSource = liat.OrderBy(q => q.Name).ToSortableBindingList();
     }
     catch (Exception e)
     {
         WebErrorLog.ErrorInstence.StartErrorLog(e);
     }
 }
 private void BindList()
 {
     try
     {
         list = ProductBussines.GetAll();
         lstProducts.Adapter = new OrderDetAdapter(this, list.OrderByDescending(q => q.Price).ToList());
     }
     catch (Exception ex)
     {
         WebErrorLog.ErrorInstence.StartErrorLog(ex);
     }
 }
Exemplo n.º 8
0
 public frmProduct(Guid guid, bool isShowMode)
 {
     InitializeComponent();
     cls = ProductBussines.Get(guid);
     grpAccount.Enabled      = !isShowMode;
     btnFinish.Enabled       = !isShowMode;
     groupPanel1.Enabled     = !isShowMode;
     groupPanel3.Enabled     = !isShowMode;
     groupPanel4.Enabled     = !isShowMode;
     groupPanel5.Enabled     = !isShowMode;
     tabControl1.SelectedTab = tabBase;
 }
Exemplo n.º 9
0
        private async void btnFinish_Click(object sender, EventArgs e)
        {
            try
            {
                if (cls.Guid == Guid.Empty)
                {
                    cls.Guid = Guid.NewGuid();
                }

                if (string.IsNullOrWhiteSpace(txtCode.Text))
                {
                    frmNotification.PublicInfo.ShowMessage("کد محصول نمی تواند خالی باشد");
                    txtCode.Focus();
                    return;
                }

                if (string.IsNullOrWhiteSpace(txtName.Text))
                {
                    frmNotification.PublicInfo.ShowMessage("عنوان نمی تواند خالی باشد");
                    txtName.Focus();
                    return;
                }

                if (string.IsNullOrWhiteSpace(txtPrice.Text))
                {
                    frmNotification.PublicInfo.ShowMessage("قیمت نمی تواند خالی باشد");
                    txtPrice.Focus();
                    return;
                }


                cls.Name       = txtName.Text.Trim();
                cls.Code       = txtCode.Text.Trim();
                cls.Price      = txtPrice.Text.ParseToDecimal();
                cls.BckUpPrice = txtBackUp.Text.ParseToDecimal();
                cls.Status     = true;

                var res = await ProductBussines.SaveAsync(cls);

                if (res.HasError)
                {
                    frmNotification.PublicInfo.ShowMessage(res.ErrorMessage);
                    return;
                }
                DialogResult = DialogResult.OK;
                Close();
            }
            catch (Exception exception)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(exception);
            }
        }
Exemplo n.º 10
0
        private async Task LoadDataAsync(bool status, string search = "")
        {
            try
            {
                list = await ProductBussines.GetAllAsync();

                Search(search, status);
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
        }
        public ActionResult Gardesh(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var list = ProductBussines.GetGardesh(id.Value);
            var prd  = db.Products.Find(id);

            ViewBag.ProductName = prd != null ? prd.Name : "";
            return(View(list));
        }
Exemplo n.º 12
0
        private async Task NextCode()
        {
            try
            {
                var prd = await ProductBussines.NextCode();

                txtCode.Text = prd;
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
        }
Exemplo n.º 13
0
        private async Task LoadDataAsync(string search = "")
        {
            try
            {
                list = await ProductBussines.GetAllAsync();

                Search(search, true);


                if (string.IsNullOrEmpty(serial))
                {
                    return;
                }
                var serialList = new List <string>();
                var code       = "";
                foreach (var item in serial.ToList())
                {
                    if (code.Length < 2)
                    {
                        code += item;
                        if (code.Length == 2)
                        {
                            serialList.Add(code);
                            code = "";
                        }
                    }
                    else
                    {
                        serialList.Add(code);
                        code = "";
                    }
                }


                foreach (var item in serialList)
                {
                    for (var i = 0; i < DGrid.RowCount; i++)
                    {
                        if (DGrid[dgCode.Index, i].Value.ToString() == item)
                        {
                            DGrid[dgChecked.Index, i].Value = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
        }
Exemplo n.º 14
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.ProductMainLayout);
            myToolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.mainPrdToolbar);
            SetSupportActionBar(myToolbar);

            var guid    = Intent.GetStringExtra("PrdGuid");
            var prdGuid = Guid.Empty;

            if (!string.IsNullOrEmpty(guid))
            {
                prdGuid = Guid.Parse(guid);
            }

            prd = ProductBussines.Get(prdGuid);


            txtName   = FindViewById <EditText>(Resource.Id.txtPrdName);
            txtCode   = FindViewById <EditText>(Resource.Id.txtPrdCode);
            txtPrice  = FindViewById <EditText>(Resource.Id.txtPrdPrice);
            txtBackUp = FindViewById <EditText>(Resource.Id.txtPrdBackUp);

            SetFonts();

            txtName.Text   = prd?.Name;
            txtCode.Text   = prd?.Code;
            txtPrice.Text  = prd?.Price.ToString("N0");
            txtBackUp.Text = prd?.BckUpPrice.ToString("N0");

            if (prd == null || prd.Guid == Guid.Empty)
            {
                txtCode.Text = ProductBussines.NextCode();
            }
        }
Exemplo n.º 15
0
        private async void btnFinish_Click(object sender, EventArgs e)
        {
            try
            {
                try
                {
                    if (cls.Guid == Guid.Empty)
                    {
                        cls.Guid = Guid.NewGuid();
                    }

                    if (string.IsNullOrEmpty(txtName.Text))
                    {
                        frmNotification.PublicInfo.ShowMessage("عنوان کالا نمی تواند خالی باشد");
                        txtName.Focus();
                        return;
                    }

                    if (string.IsNullOrEmpty(txtCode.Text))
                    {
                        frmNotification.PublicInfo.ShowMessage("کد کالا نمی تواند خالی باشد");
                        txtCode.Focus();
                        return;
                    }

                    if (!await ProductBussines.CheckName(cls.Guid, txtName.Text.Trim()))
                    {
                        frmNotification.PublicInfo.ShowMessage("عنوان وارد شده تکراری است");
                        txtName.Focus();
                        return;
                    }

                    cls.Code        = txtCode.Text.Trim();
                    cls.Name        = txtName.Text.Trim();
                    cls.Description = txtDesc.Text;
                    cls.Price       = txtPrice.Text.ParseToDecimal();
                    cls.ShortDesc   = txtShortDesc.Text;
                    if (string.IsNullOrEmpty(cls.ImageName))
                    {
                        cls.ImageName = "No.png";
                    }
                    var res = await cls.SaveAsync();

                    if (res.HasError)
                    {
                        frmNotification.PublicInfo.ShowMessage(res.ErrorMessage);
                        return;
                    }
                    DialogResult = DialogResult.OK;
                    frmLoading.PublicInfo.ShowForm();
                    Close();
                }
                catch (Exception exception)
                {
                    WebErrorLog.ErrorInstence.StartErrorLog(exception);
                }
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
        }
Exemplo n.º 16
0
 public frmProductMain()
 {
     InitializeComponent();
     cls = new ProductBussines();
 }
Exemplo n.º 17
0
 public frmProduct()
 {
     InitializeComponent();
     cls = new ProductBussines();
     tabControl1.SelectedTab = tabBase;
 }
Exemplo n.º 18
0
 public frmProductMain(Guid guid)
 {
     InitializeComponent();
     cls             = ProductBussines.Get(guid);
     txtCode.Enabled = false;
 }