public override bool OnOptionsItemSelected(IMenuItem item)
        {
            try
            {
                var res = new ReturnedSaveFuncInfo();
                res.AddReturnedValue(CheckValidation());
                if (res.HasError)
                {
                    Toast.MakeText(this, res.ErrorMessage, ToastLength.Short).Show();
                    return(base.OnOptionsItemSelected(item));
                }


                order.ContractCode = lblOrderCode.Text;
                order.CustomerGuid = customerGuid;
                order.Guid         = Guid.NewGuid();
                order.Date         = DateTime.Now;
                order.Discount     = txtOrderMainDiscount.Text.ParseToDecimal();
                order.Modified     = DateTime.Now;
                order.Status       = true;
                order.Sum          = lblOrderMainSum.Text.ParseToDecimal();
                order.Total        = (order?.DetList?.Sum(q => q.Total) ?? 0) - order.Discount;
                order.UserGuid     = CurrentUser.User.Guid;



                OrderBussines.Save(order);
                Finish();
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
            return(base.OnOptionsItemSelected(item));
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.OrderMainLayout);
            FindElements();
            SetSupportActionBar(myToolbar);
            BindList();
            SetFonts();

            order             = new OrderBussines();
            lblOrderCode.Text = OrderBussines.NextCode();
            lblDateSh.Text    = order?.DateSh;
            txtOrderMainLearningCount.Text = "1";
            txtOrderMainDiscount.Text      = order?.DetList?.Sum(q => q.Discount).ToString("N0");
            SetLables();

            var          names   = CustomerBussines.GetAll().Select(q => q.Name).ToList();
            ArrayAdapter adapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerItem, names);

            txtOrderMainCustomerName.Adapter = adapter;

            OrderBussines.OnDetailsChanged   += OrderBussines_OnDetailsChanged;
            txtOrderMainDiscount.TextChanged += TxtOrderMainDiscount_TextChanged;
        }
Beispiel #3
0
        private async Task LoadDataAsync(string search = "")
        {
            try
            {
                if (InvokeRequired)
                {
                    Invoke(new MethodInvoker(() =>
                    {
                        if (cmbUsers.SelectedValue == null)
                        {
                            return;
                        }
                    }));
                }
                else if (cmbUsers.SelectedValue == null)
                {
                    return;
                }
                list = await OrderBussines.GetAllAsync();

                Search(search);
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
        }
Beispiel #4
0
        private void mnuPrint_Click(object sender, EventArgs e)
        {
            try
            {
                if (DGrid.RowCount <= 0 || DGrid.CurrentRow == null)
                {
                    return;
                }
                var guid  = (Guid)DGrid[dgGuid.Index, DGrid.CurrentRow.Index].Value;
                var order = OrderBussines.Get(guid);
                if (order == null)
                {
                    return;
                }

                var reportList = new List <OrderReportBussines>();

                foreach (var item in order.DetList)
                {
                    reportList.Add(new OrderReportBussines()
                    {
                        CompanyName          = "گروه فنی و مهندسی آراد",
                        CompanyTell          = "09382420272",
                        ContractCode         = order.ContractCode,
                        CustomerAddress      = order.Customer?.Address,
                        CustomerName         = order.CustomerName,
                        CustomerSerialNumber = order.Customer?.AppSerial,
                        CustomerTell         = order.Customer?.Tell1,
                        DateSh          = order.DateSh,
                        OdrerDiscount   = order.Discount,
                        OrderSum        = order.Sum,
                        OrderTotal      = order.Total,
                        OrderUserName   = order.UserName,
                        ProductCount    = item.Count,
                        ProductDiscount = item.Discount,
                        ProductName     = item.ProductName,
                        ProductPrice    = item.Price,
                        ProductTotal    = item.Total,
                        Time            = order.Date.ToShortTimeString(),
                        OrderTotalName  = $"{NumberToString.Num2Str(order.Total.ToString().ParseToDouble().ToString())} ریال"
                    });
                }

                var cls = new ReportGenerator(StiType.DepartmentOrder, EnPrintType.Pdf_A4)
                {
                    Lst = new List <object>(reportList?.OrderBy(q => q.ProductName))
                };
                cls.PrintNew();
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
        }
Beispiel #5
0
        private async void btnFinish_Click(object sender, EventArgs e)
        {
            try
            {
                if (_cls.Guid == Guid.Empty)
                {
                    _cls.Guid     = Guid.NewGuid();
                    _cls.UserGuid = CurentUser.CurrentUser.Guid;
                    _cls.Status   = true;
                }

                if (_customer == null)
                {
                    frmNotification.PublicInfo.ShowMessage("خریدار نمی تواند خالی باشد");
                    btnSearchCust.Focus();
                    return;
                }

                if (_cls.DetList == null || _cls.DetList.Count <= 0)
                {
                    frmNotification.PublicInfo.ShowMessage("کالایی انتخاب نشده است");
                    return;
                }

                _cls.Total        = _cls.DetList.Sum(q => q.Total);
                _cls.Discount     = _cls.DetList.Sum(q => q.Discount);
                _cls.ContractCode = lblConCode.Text.Trim();
                _cls.Sum          = _cls.Total + _cls.Discount;
                _cls.CustomerGuid = _customer.Guid;

                foreach (var item in _cls.DetList)
                {
                    item.OrderGuid = _cls.Guid;
                }

                var res = await OrderBussines.SaveAsync(_cls);

                if (res.HasError)
                {
                    frmNotification.PublicInfo.ShowMessage(res.ErrorMessage);
                    return;
                }
                DialogResult = DialogResult.OK;
                Close();
            }
            catch (Exception exception)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(exception);
            }
        }
 private void BindList()
 {
     try
     {
         list = OrderBussines.GetAll();
         if (CurrentUser.User.Type != EnUserType.Manager)
         {
             list = list.Where(q => q.UserGuid == CurrentUser.User.Guid).ToList();
         }
         lstOrders.Adapter = new OrderAdapter(this, list.OrderByDescending(q => q.Date).ToList());
     }
     catch (Exception ex)
     {
         WebErrorLog.ErrorInstence.StartErrorLog(ex);
     }
 }
        private async Task SetLabelsAsync()
        {
            try
            {
                var cust = await CustomerBussines.GetAllAsync();

                var order = await OrderBussines.GetAllAsync();

                var rece = await ReceptionBussines.GetAllAsync();

                var pardakht = await PardakhtBussines.GetAllAsync();

                var currentUser = CurentUser.CurrentUser;

                Invoke(new MethodInvoker(() =>
                {
                    lblAllCustomers.Text  = lblMyCustomers.Text = "";
                    lblAllOrders.Text     = lblMyOrders.Text = "";
                    lblAllPardakht.Text   = lblMyPardakht.Text = lblSumPardakht.Text = "";
                    lblAllReceptions.Text = lblMyReceptions.Text = lblSumReception.Text = "";

                    lblAllCustomers.Text = (cust?.Count ?? 0).ToString();
                    lblMyCustomers.Text  = (cust?.Where(q => q.UserGuid == currentUser.Guid)?.Count() ?? 0).ToString();

                    lblAllOrders.Text = (order?.Count ?? 0).ToString();
                    lblMyOrders.Text  = (order?.Where(q => q.UserGuid == currentUser.Guid)?.Count() ?? 0).ToString();

                    lblAllPardakht.Text = (pardakht?.Count ?? 0).ToString();
                    lblMyPardakht.Text  =
                        (pardakht?.Where(q => q.UserGuid == currentUser.Guid)?.Count() ?? 0).ToString();
                    lblSumPardakht.Text =
                        (pardakht?.Where(q => q.UserGuid == currentUser.Guid)?.Sum(q => q.TotalPrice) ?? 0)
                        .ToString("N0");

                    lblAllReceptions.Text = (rece?.Count ?? 0).ToString();
                    lblMyReceptions.Text  = (rece?.Where(q => q.UserGuid == currentUser.Guid)?.Count() ?? 0).ToString();
                    lblSumReception.Text  =
                        (rece?.Where(q => q.UserGuid == currentUser.Guid)?.Sum(q => q.TotalPrice) ?? 0).ToString("N0");
                }));
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
        }
Beispiel #8
0
        private void HolderChkItemClick(object sender, EventArgs e)
        {
            var chk = sender as CheckBox;
            var pos = ((MyWrapper <int>)chk.Tag).value;

            prd = _list[pos];
            var a = new OrderDetailBussines()
            {
                Guid      = Guid.NewGuid(),
                Price     = prd.Price,
                Discount  = 0,
                Total     = prd.Price,
                Modified  = DateTime.Now,
                Status    = true,
                OrderGuid = Guid.Empty,
                PrdGuid   = prd.Guid
            };

            OrderBussines.RaiseEvent(a);
        }
Beispiel #9
0
        private async void mnuDelete_Click(object sender, EventArgs e)
        {
            try
            {
                if (DGrid.RowCount <= 0)
                {
                    return;
                }
                if (DGrid.CurrentRow == null)
                {
                    return;
                }

                if (MessageBox.Show(
                        $"آیا از حذف قرارداد {DGrid[dgCode.Index, DGrid.CurrentRow.Index].Value} اطمینان دارید؟", "حذف",
                        MessageBoxButtons.YesNo, MessageBoxIcon.Question) !=
                    DialogResult.Yes)
                {
                    return;
                }

                var guid      = (Guid)DGrid[dgGuid.Index, DGrid.CurrentRow.Index].Value;
                var reception = await OrderBussines.GetAsync(guid);

                reception.Status = false;
                var res = await OrderBussines.RemoveAsync(reception);

                if (res.HasError)
                {
                    frmNotification.PublicInfo.ShowMessage(res.ErrorMessage);
                    return;
                }

                await LoadDataAsync();
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
        }
Beispiel #10
0
        private async Task SetDataAsync()
        {
            try
            {
                await SetProductsAsync();

                UpdateDets();
                SetCustomer(_cls.CustomerGuid);
                grpProduct.Enabled = false;
                lblConCode.Text    = _cls?.ContractCode;
                lblDateNow.Text    = _cls?.DateSh;
                lblTimeNow.Text    = DateTime.Now.ToShortTimeString();

                if (_cls?.Guid == Guid.Empty)
                {
                    lblConCode.Text = await OrderBussines.NextCodeAsync();
                }
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
        }
Beispiel #11
0
 public frmOrderMain(Guid guid)
 {
     InitializeComponent();
     _cls = OrderBussines.Get(guid);
 }
Beispiel #12
0
 public frmOrderMain()
 {
     InitializeComponent();
     _cls = new OrderBussines();
 }