Exemplo n.º 1
0
        public async Task <ReceptionCheckBussines> GetAsync(string _connectionString, Guid guid)
        {
            ReceptionCheckBussines item = null;

            try
            {
                using (var cn = new SqlConnection(_connectionString))
                {
                    var cmd = new SqlCommand("sp_ReceptionCheck_Get", cn)
                    {
                        CommandType = CommandType.StoredProcedure
                    };
                    cmd.Parameters.AddWithValue("@Guid", guid);

                    await cn.OpenAsync();

                    var dr = await cmd.ExecuteReaderAsync();

                    if (dr.Read())
                    {
                        item = LoadData(dr);
                    }
                    cn.Close();
                }
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }

            return(item);
        }
Exemplo n.º 2
0
        private ReceptionCheckBussines LoadData(SqlDataReader dr)
        {
            var item = new ReceptionCheckBussines();

            try
            {
                item.Guid     = (Guid)dr["Guid"];
                item.Modified = (DateTime)dr["Modified"];
                item.BankName = dr["BankName"].ToString();
                item.DateM    = (DateTime)dr["DateM"];
                if (dr["MasterGuid"] != DBNull.Value)
                {
                    item.MasterGuid = (Guid)dr["MasterGuid"];
                }
                item.Description        = dr["Description"].ToString();
                item.CheckNumber        = dr["CheckNumber"].ToString();
                item.PoshtNomre         = dr["PoshtNomre"].ToString();
                item.Price              = (decimal)dr["Price"];
                item.CheckStatus        = (EnCheckM)dr["CheckStatus"];
                item.DateSarResid       = (DateTime)dr["DateSarResid"];
                item.SandouqTafsilGuid  = (Guid)dr["SandouqTafsilGuid"];
                item.SandouqMoeinGuid   = (Guid)dr["SandouqMoeinGuid"];
                item.ServerDeliveryDate = (DateTime)dr["ServerDeliveryDate"];
                item.ServerStatus       = (ServerStatus)dr["ServerStatus"];
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }

            return(item);
        }
Exemplo n.º 3
0
        private object GetRowInfo(int index)
        {
            try
            {
                var o = new object();
                if (index > DGrid.RowCount - 1)
                {
                    return(null);
                }

                if (DGrid[DGType.Index, index].Value.ToString() == "نقد")
                {
                    var temp = new ReceptionNaqdBussines()
                    {
                        Guid              = (Guid)(DGrid[DgGuid.Index, index].Value),
                        Price             = (DGrid[DGPrice.Index, index].Value.ToString().ParseToDecimal()),
                        SandouqTafsilGuid = (Guid)(DGrid[DGTafsilGuid.Index, index].Value),
                        DateM             = (DateTime)(DGrid[DGDate.Index, index].Value),
                        Description       = DGrid[DG_TempDescription.Index, index].Value.ToString()
                    };
                    o = temp;
                }
                else if (DGrid[DGType.Index, index].Value.ToString() == "چک")
                {
                    var temp = new ReceptionCheckBussines()
                    {
                        Guid              = (Guid)(DGrid[DgGuid.Index, index].Value),
                        Price             = (DGrid[DGPrice.Index, index].Value.ToString().ParseToDecimal()),
                        BankName          = DGrid[DGCheckBankName.Index, index].Value.ToString(),
                        DateM             = (DateTime)(DGrid[DGDate.Index, index].Value),
                        CheckNumber       = DGrid[DGNumber.Index, index].Value.ToString(),
                        CheckStatus       = (EnCheckM)(DGrid[DGCheckStatus.Index, index].Value),
                        PoshtNomre        = DGrid[DGPoshtNomre.Index, index].Value.ToString(),
                        Description       = DGrid[DG_TempDescription.Index, index].Value.ToString(),
                        SandouqTafsilGuid = (Guid)(DGrid[DGTafsilGuid.Index, index].Value),
                        DateSarResid      = (DateTime)(DGrid[DGDateSarresid.Index, index].Value)
                    };
                    o = temp;
                }
                else if (DGrid[DGType.Index, index].Value.ToString() == "حواله")
                {
                    var temp = new ReceptionHavaleBussines()
                    {
                        Guid           = (Guid)(DGrid[DgGuid.Index, index].Value),
                        Price          = (DGrid[DGPrice.Index, index].Value.ToString().ParseToDecimal()),
                        BankTafsilGuid = (Guid)(DGrid[DGTafsilGuid.Index, index].Value),
                        DateM          = (DateTime)(DGrid[DGDate.Index, index].Value),
                        PeygiriNumber  = DGrid[DGNumber.Index, index].Value.ToString(),
                        Description    = DGrid[DG_TempDescription.Index, index].Value.ToString(),
                    };
                    o = temp;
                }
                return(o);
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                return(null);
            }
        }
        private ReceptionBussines LoadData(SqlDataReader dr)
        {
            var item = new ReceptionBussines();

            try
            {
                item.Guid               = (Guid)dr["Guid"];
                item.Modified           = (DateTime)dr["Modified"];
                item.DateM              = (DateTime)dr["DateM"];
                item.Description        = dr["Description"].ToString();
                item.Number             = (long)dr["Number"];
                item.TafsilGuid         = (Guid)dr["TafsilGuid"];
                item.MoeinGuid          = (Guid)dr["MoeinGuid"];
                item.UserGuid           = (Guid)dr["UserGuid"];
                item.SanadNumber        = (long)dr["SanadNumber"];
                item.TafsilName         = dr["TafsilName"].ToString();
                item.UserName           = dr["UserName"].ToString();
                item.ServerDeliveryDate = (DateTime)dr["ServerDeliveryDate"];
                item.ServerStatus       = (ServerStatus)dr["ServerStatus"];
                item.IsModified         = true;
                item.CheckList          = AsyncContext.Run(() => ReceptionCheckBussines.GetAllAsync(item.Guid));
                item.HavaleList         = AsyncContext.Run(() => ReceptionHavaleBussines.GetAllAsync(item.Guid));
                item.NaqdList           = AsyncContext.Run(() => ReceptionNaqdBussines.GetAllAsync(item.Guid));
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }

            return(item);
        }
Exemplo n.º 5
0
        public static async Task <ReturnedSaveFuncInfo> BargashtAsync(ReceptionCheckBussines cls)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                cls.CheckStatus = EnCheckM.Bargashti;
                cls.Modified    = DateTime.Now;
                res.AddReturnedValue(await cls.SaveAsync());

                var reception = await ReceptionBussines.GetAsync(cls.MasterGuid.Value);

                var pardazande = await TafsilBussines.GetAsync(reception.TafsilGuid);

                var sanad = new SanadBussines()
                {
                    Guid        = Guid.NewGuid(),
                    Modified    = DateTime.Now,
                    Description = $"برگشت زدن چک دریافتنی * شناره: {cls.CheckNumber} بانک صادرکننده: {cls.BankName} * پردازنده: {pardazande.Name}",
                    DateM       = DateTime.Now,
                    Number      = await SanadBussines.NextNumberAsync(),
                    SanadStatus = EnSanadStatus.Temporary,
                    SanadType   = EnSanadType.Auto,
                    UserGuid    = UserBussines.CurrentUser.Guid
                };
                //بستانکار--اسناد
                sanad.AddToListSanad(new SanadDetailBussines()
                {
                    Guid        = Guid.NewGuid(),
                    Modified    = DateTime.Now,
                    Description = $"برگشت زدن چک {cls.CheckNumber} {cls.BankName} * پردازنده: {pardazande.Name}",
                    Debit       = 0,
                    Credit      = cls.Price,
                    TafsilGuid  = cls.SandouqTafsilGuid,
                    MasterGuid  = sanad.Guid,
                    MoeinGuid   = cls.SandouqMoeinGuid
                });
                //بدهکار--شخص
                sanad.AddToListSanad(new SanadDetailBussines()
                {
                    Guid        = Guid.NewGuid(),
                    Modified    = DateTime.Now,
                    Description = $"برگشت زدن چک {cls.CheckNumber} {cls.BankName} * پردازنده: {pardazande.Name}",
                    Debit       = cls.Price,
                    Credit      = 0,
                    TafsilGuid  = pardazande.Guid,
                    MasterGuid  = sanad.Guid,
                    MoeinGuid   = ParentDefaults.MoeinCoding.CLSMoein10304
                });

                res.AddReturnedValue(await sanad.SaveAsync());
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                res.AddReturnedValue(ex);
            }

            return(res);
        }
Exemplo n.º 6
0
        private async void mnuViewSanad_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 avalDore = (bool)DGrid[dgAvalDore.Index, DGrid.CurrentRow.Index].Value;
                if (!avalDore)
                {
                    var str = await ReceptionCheckBussines.GetAsync(guid);

                    var rec = await ReceptionBussines.GetAsync(str.MasterGuid.Value);

                    var sanad = await SanadBussines.GetAsync(rec.SanadNumber);

                    var frm_ = new frmSanadMain(sanad.Guid, true);
                    frm_.ShowDialog(this);
                    return;
                }

                var frm = new frmCheckM_AvalDore(guid, true);
                frm.ShowDialog(this);
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
        }
Exemplo n.º 7
0
 public frmReceptionCheck(Guid guid)
 {
     InitializeComponent();
     cls               = ReceptionCheckBussines.Get(guid);
     ucHeader.Text     = "دریافت چک";
     grp.Enabled       = false;
     btnFinish.Enabled = false;
 }
Exemplo n.º 8
0
 public frmCheckM_Vagozar(ReceptionCheckBussines cls, HesabType hType)
 {
     InitializeComponent();
     _oldTafsil    = TafsilBussines.Get(cls.SandouqTafsilGuid);
     _isAvalDore   = false;
     _newHesabType = hType;
     rec           = cls;
 }
Exemplo n.º 9
0
        private async void mnuBatel_Click(object sender, EventArgs e)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                if (DGrid.RowCount <= 0 || DGrid.CurrentRow == null)
                {
                    return;
                }
                var st = (EnCheckM)DGrid[dgStatus.Index, DGrid.CurrentRow.Index].Value;
                if (st == EnCheckM.Bargashti || st == EnCheckM.Naqd)
                {
                    frmNotification.PublicInfo.ShowMessage($"شما مجاز به ابطال چک {st.GetDisplay()} نمی باشید");
                    return;
                }
                var guid     = (Guid)DGrid[dgGuid.Index, DGrid.CurrentRow.Index].Value;
                var avalDore = (bool)DGrid[dgAvalDore.Index, DGrid.CurrentRow.Index].Value;

                if (MessageBox.Show("آیا از ابطال چک اطمینان دارید؟", "پیغام سیستم", MessageBoxButtons.YesNo,
                                    MessageBoxIcon.Question) ==
                    DialogResult.No)
                {
                    return;
                }

                if (!avalDore)
                {
                    var str = await ReceptionCheckBussines.GetAsync(guid);

                    var rec = await ReceptionBussines.GetAsync(str.MasterGuid.Value);

                    rec.RemoveFromDetList(str);
                    res.AddReturnedValue(await rec.SaveAsync());
                    return;
                }

                var cls = await ReceptionCheckAvalDoreBussines.GetAsync(guid);

                res.AddReturnedValue(await cls.RemoveAsync());
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                res.AddReturnedValue(ex);
            }
            finally
            {
                if (res.HasError)
                {
                    this.ShowError(res, "خطا در ابطال چک دریافتنی");
                }
                else
                {
                    await LoadDataAsync(txtSearch.Text);
                }
            }
        }
Exemplo n.º 10
0
        private async Task LoadDataAsync(string search = "")
        {
            try
            {
                var list = await ReceptionCheckBussines.GetAllViewModeAsync(search);

                Invoke(new MethodInvoker(() => CheckBindingSource.DataSource = list.ToSortableBindingList()));
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
        }
Exemplo n.º 11
0
        private async void mnuVagozarBank_Click(object sender, EventArgs e)
        {
            try
            {
                if (DGrid.RowCount <= 0 || DGrid.CurrentRow == null)
                {
                    return;
                }
                var st = (EnCheckM)DGrid[dgStatus.Index, DGrid.CurrentRow.Index].Value;
                if (st == EnCheckM.Kharj || st == EnCheckM.Naqd)
                {
                    frmNotification.PublicInfo.ShowMessage($"شما مجاز به واگذارکردن چک {st.GetDisplay()} نمی باشید");
                    return;
                }
                var guid     = (Guid)DGrid[dgGuid.Index, DGrid.CurrentRow.Index].Value;
                var avalDore = (bool)DGrid[dgAvalDore.Index, DGrid.CurrentRow.Index].Value;

                if (MessageBox.Show("آیا از واگذارکردن چک اطمینان دارید؟", "پیغام سیستم", MessageBoxButtons.YesNo,
                                    MessageBoxIcon.Question) ==
                    DialogResult.No)
                {
                    return;
                }

                if (!avalDore)
                {
                    var str = await ReceptionCheckBussines.GetAsync(guid);

                    var frm = new frmCheckM_Vagozar(str, HesabType.Bank);
                    if (frm.ShowDialog(this) == DialogResult.OK)
                    {
                        await LoadDataAsync(txtSearch.Text);
                    }
                    return;
                }

                var cls = await ReceptionCheckAvalDoreBussines.GetAsync(guid);

                var frm_ = new frmCheckM_Vagozar(cls, HesabType.Bank);
                if (frm_.ShowDialog(this) == DialogResult.OK)
                {
                    await LoadDataAsync(txtSearch.Text);
                }
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
        }
Exemplo n.º 12
0
        private static async Task <ReturnedSaveFuncInfo> NaqdBargashtAsync(ReceptionCheckBussines cls, SanadBussines sanad)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                var reception = await ReceptionBussines.GetAsync(cls.MasterGuid.Value);

                var pardazande = await TafsilBussines.GetAsync(reception.TafsilGuid);

                //بستانکار--شخص
                sanad.AddToListSanad(new SanadDetailBussines()
                {
                    Guid        = Guid.NewGuid(),
                    Modified    = DateTime.Now,
                    Description = $"استرداد چک {cls.CheckNumber} {cls.BankName} * پردازنده: {pardazande.Name}",
                    Debit       = 0,
                    Credit      = cls.Price,
                    TafsilGuid  = pardazande.Guid,
                    MasterGuid  = sanad.Guid,
                    MoeinGuid   = ParentDefaults.MoeinCoding.CLSMoein10304
                });
                //بدهکار--اسناد
                sanad.AddToListSanad(new SanadDetailBussines()
                {
                    Guid        = Guid.NewGuid(),
                    Modified    = DateTime.Now,
                    Description = $"استرداد چک {cls.CheckNumber} {cls.BankName} * پردازنده: {pardazande.Name}",
                    Debit       = cls.Price,
                    Credit      = 0,
                    TafsilGuid  = cls.SandouqTafsilGuid,
                    MasterGuid  = sanad.Guid,
                    MoeinGuid   = cls.SandouqMoeinGuid
                });

                res.AddReturnedValue(await sanad.SaveAsync());
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                res.AddReturnedValue(ex);
            }

            return(res);
        }
Exemplo n.º 13
0
        public async Task <ReturnedSaveFuncInfo> SaveAsync(ReceptionCheckBussines item, SqlTransaction tr)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                var cmd = new SqlCommand("sp_ReceptionCheck_Insert", tr.Connection, tr)
                {
                    CommandType = CommandType.StoredProcedure
                };
                cmd.Parameters.AddWithValue("@guid", item.Guid);
                cmd.Parameters.AddWithValue("@modif", item.Modified);
                cmd.Parameters.AddWithValue("@bankName", item.BankName ?? "");
                cmd.Parameters.AddWithValue("@desc", item.Description ?? "");
                cmd.Parameters.AddWithValue("@dateM", item.DateM);
                cmd.Parameters.AddWithValue("@masterGuid", item.MasterGuid);
                cmd.Parameters.AddWithValue("@checkNumber", item.CheckNumber ?? "");
                cmd.Parameters.AddWithValue("@poshtNomre", item.PoshtNomre ?? "");
                cmd.Parameters.AddWithValue("@price", item.Price);
                cmd.Parameters.AddWithValue("@checkStatus", (int)item.CheckStatus);
                cmd.Parameters.AddWithValue("@sarResid", item.DateSarResid);
                cmd.Parameters.AddWithValue("@sandouqTafsilGuid", item.SandouqTafsilGuid);
                if (item.SandouqMoeinGuid == Guid.Empty)
                {
                    item.SandouqMoeinGuid = ParentDefaults.MoeinCoding.CLSMoein10104;
                }
                cmd.Parameters.AddWithValue("@sandouqMoeinGuid", item.SandouqMoeinGuid);
                cmd.Parameters.AddWithValue("@isAvalDore", item.isAvalDore);
                cmd.Parameters.AddWithValue("@serverSt", (short)item.ServerStatus);
                cmd.Parameters.AddWithValue("@serverDate", item.ServerDeliveryDate);

                await cmd.ExecuteNonQueryAsync();
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                res.AddReturnedValue(ex);
            }

            return(res);
        }
Exemplo n.º 14
0
 public frmReceptionCheck(ReceptionCheckBussines temp)
 {
     InitializeComponent();
     cls           = temp ?? new ReceptionCheckBussines();
     ucHeader.Text = "دریافت چک";
 }