示例#1
0
        public void CancelCollection(BillCollectionInfo billCollection)
        {
            try
            {
                UpadteCollectionAudit(billCollection.ColectionId);

                _databaseManager = new MssqlDatabaseManager();
                _databaseManager.SetConnectionString = MtbBillCollection.WebConfigManager.GetCollDBConnString();;
                //_databaseManager.BeginTransaction();
                _databaseManager.OpenDatabaseConnection();

                string commandString = "UPDATE Collection SET  CollStatusId= " + MtbBillCollection.Global.Definitions.CollectionStatus.Value.Cancelled;
                commandString += ", ApproveBy=" + billCollection.InstApprovedBy + ",ApproveDate='" + billCollection.InstApprovedDate + "' ";

                commandString += " WHERE CollectionId=" + billCollection.ColectionId;
                _databaseManager.ExcecuteCommand(commandString);

                //_databaseManager.Commit();
            }
            catch (Exception exception)
            {
                throw exception;
                //_databaseManager.RollBack();
            }
            finally
            {
                _databaseManager.CloseDatabaseConnection();
            }
        }
示例#2
0
        public void ClearCollection(BillCollectionInfo billCollInfo)
        {
            try
            {
                UpadteCollectionAudit(billCollInfo.ColectionId);
                _databaseManager = new MssqlDatabaseManager();
                _databaseManager.SetConnectionString = MtbBillCollection.WebConfigManager.GetCollDBConnString();;
                //_databaseManager.BeginTransaction();
                _databaseManager.OpenDatabaseConnection();

                string commandString = "UPDATE Collection   SET InstrCleared = 1 ,InstClearedBy = " + billCollInfo.InstClearedBy + " ,InstClearingDate ='" + billCollInfo.InstClearingDate + "' WHERE CollectionId=" + billCollInfo.ColectionId;

                _databaseManager.ExcecuteCommand(commandString);

                //_databaseManager.Commit();
            }
            catch
            {
                //_databaseManager.RollBack();
            }
            finally
            {
                _databaseManager.CloseDatabaseConnection();
            }
        }
示例#3
0
        public void UpdateCollectionInformation(BillCollectionInfo billCollection)
        {
            try
            {
                UpadteCollectionAudit(billCollection.ColectionId);
                _databaseManager = new MssqlDatabaseManager();
                _databaseManager.SetConnectionString = MtbBillCollection.WebConfigManager.GetCollDBConnString();;
                //_databaseManager.BeginTransaction();
                _databaseManager.OpenDatabaseConnection();
                string commandString = "UPDATE Collection SET  ClientId  = " + billCollection.ClientId + " , CollDate  = '" + billCollection.CollDate + "'";
                commandString += ", ProductId  = " + billCollection.ProductId + ", BranchCode  = '" + billCollection.BranchCode + "', CollectionTypeId  = " + billCollection.CollectionTypeId;
                commandString += ", CollFrom  = '" + billCollection.CollFrom + "', InstTypeId  = " + billCollection.InstTypeId + ", InstNumber  = '" + billCollection.InstNumber + "'";
                commandString += ", InstDate  ='" + billCollection.InstDate + "', CollAmount  = " + billCollection.CollAmount + ", InstBankCode  = " + billCollection.InstBankCode;
                commandString += ", Remarks  = '" + billCollection.Remarks + "',ApproveBy=" + billCollection.InstApprovedBy + ",ApproveDate='" + billCollection.InstApprovedDate + "'";
                commandString += " WHERE CollectionId=" + billCollection.ColectionId;

                _databaseManager.ExcecuteCommand(commandString);

                //_databaseManager.Commit();
            }
            catch
            {
                //_databaseManager.RollBack();
            }
            finally
            {
                _databaseManager.CloseDatabaseConnection();
            }
        }
示例#4
0
        public BillCollectionInfo GetCollectionInformtion(string collectionId)
        {
            StringBuilder sb = new StringBuilder();

            try
            {
                _databaseManager = new MssqlDatabaseManager();
                _databaseManager.SetConnectionString = MtbBillCollection.WebConfigManager.GetCollDBConnString();;
                _databaseManager.OpenDatabaseConnection();

                //Change date format
                //We have read the date as dd/MM/yyyy. need to convert them in MM/dd/yyyy for sql date comparison

                sb.Append("SELECT ClientId , CollDate , ProductId, BranchCode , CollectionTypeId , CollFrom ,InstTypeId , InstNumber");
                sb.Append(" , InstDate , CollAmount, InstBankCode , Remarks, CollStatusId,ApproveBy,ApproveDate FROM Collection ");
                sb.Append("Where CollectionId=");
                sb.Append(collectionId);
                DataTable          dt = _databaseManager.GetDataTable(sb.ToString());
                BillCollectionInfo billColectionInfo = new BillCollectionInfo();
                billColectionInfo.ClientId         = Convert.ToInt32(dt.Rows[0]["ClientId"].ToString());
                billColectionInfo.CollDate         = dt.Rows[0]["CollDate"].ToString();
                billColectionInfo.ProductId        = Convert.ToInt32(dt.Rows[0]["ProductId"].ToString());
                billColectionInfo.BranchCode       = dt.Rows[0]["BranchCode"].ToString();
                billColectionInfo.CollectionTypeId = Convert.ToInt32(dt.Rows[0]["CollectionTypeId"].ToString());
                billColectionInfo.CollFrom         = dt.Rows[0]["CollFrom"].ToString();
                billColectionInfo.InstTypeId       = Convert.ToInt32(dt.Rows[0]["InstTypeId"].ToString());
                billColectionInfo.InstNumber       = dt.Rows[0]["InstNumber"].ToString();
                billColectionInfo.InstDate         = dt.Rows[0]["InstDate"].ToString();
                billColectionInfo.CollAmount       = Convert.ToDecimal(dt.Rows[0]["CollAmount"].ToString());
                billColectionInfo.InstBankCode     = Convert.ToInt32((dt.Rows[0]["InstBankCode"].ToString() == "" ? "0" : dt.Rows[0]["InstBankCode"].ToString()));
                billColectionInfo.Remarks          = dt.Rows[0]["Remarks"].ToString();
                billColectionInfo.CollStatus       = Convert.ToInt32(dt.Rows[0]["CollStatusId"].ToString());
                billColectionInfo.InstApprovedBy   = Convert.ToInt32("0" + dt.Rows[0]["ApproveBy"].ToString());
                billColectionInfo.InstApprovedDate = dt.Rows[0]["ApproveDate"].ToString();

                return(billColectionInfo);
            }
            catch (Exception e)
            {
                return(null);
            }
            finally
            {
                _databaseManager.CloseDatabaseConnection();
            }
            //return null;
        }
示例#5
0
        public void SaveCollectionInformation(BillCollectionInfo billCollection)
        {
            try
            {
                _databaseManager = new MssqlDatabaseManager();
                _databaseManager.SetConnectionString = MtbBillCollection.WebConfigManager.GetCollDBConnString();;
                //_databaseManager.BeginTransaction();
                _databaseManager.OpenDatabaseConnection();
                string commandString = "INSERT INTO Collection  (ClientId,CollDate,ProductId,BranchCode,CollectionTypeId,CollFrom,InstTypeId ,InstNumber,InstRecvdBy";
                commandString += "  ,InstDate,CollAmount ";
                if (billCollection.InstBankCode != 0)
                {
                    commandString += ",InstBankCode ";
                }
                commandString += " ,Remarks,CollStatusId) VALUES (";
                commandString += billCollection.ClientId + ",'" + billCollection.CollDate + "'," + billCollection.ProductId + ",'";
                commandString += billCollection.BranchCode + "'," + billCollection.CollectionTypeId + ",'" + billCollection.CollFrom + "',";
                commandString += billCollection.InstTypeId + ",'" + billCollection.InstNumber + "'," + billCollection.InstRecvdBy + ",'";
                commandString += billCollection.InstDate + "'," + billCollection.CollAmount;
                if (billCollection.InstBankCode != 0)
                {
                    commandString += "," + billCollection.InstBankCode;
                }
                commandString += " ,'" + billCollection.Remarks + "'," + billCollection.CollStatus + " )";

                _databaseManager.ExcecuteCommand(commandString);

                //_databaseManager.Commit();
            }
            catch (Exception exception)
            {
                throw exception;
                //_databaseManager.RollBack();
            }
            finally
            {
                _databaseManager.CloseDatabaseConnection();
            }
        }
示例#6
0
        protected void SaveButton_Click(object sender, ImageClickEventArgs e)
        {
            if (IsValidEntry() == true)
            {
                if (ViewState[MtbBillCollection.Global.Definitions.SessionVariable.Value.SaveMode] != null)
                {
                    _saveMode = Convert.ToBoolean(ViewState[MtbBillCollection.Global.Definitions.SessionVariable.Value.SaveMode].ToString());
                }
                BillCollectionInfo bilCollectioninfo = new BillCollectionInfo();
                bilCollectioninfo.ClientId  = Convert.ToInt32(ClientList.SelectedValue); //get it from session
                bilCollectioninfo.CollDate  = DateTime.Now.ToString();
                bilCollectioninfo.ProductId = Convert.ToInt32(ProductList.SelectedValue);

                InstrumentDate.Text = DateTime.Now.Date.ToString("dd/MM/yyyy");
                DateTime creationTime = DateTime.Now.Date;

                if (!DateTime.TryParseExact(InstrumentDate.Text, "dd/MM/yyyy",
                                            CultureInfo.InvariantCulture, DateTimeStyles.None, out creationTime))
                {
                    // Parse failed
                    creationTime = DateTime.Now.Date;
                }


                bilCollectioninfo.BranchCode       = Session[MtbBillCollection.Global.Definitions.SessionVariable.Value.BranchCode].ToString();
                bilCollectioninfo.CollectionTypeId = Convert.ToInt32(CollectionTypeList.SelectedValue);
                bilCollectioninfo.CollFrom         = CollectionFrom.Text;
                bilCollectioninfo.InstTypeId       = Convert.ToInt32(TranssactionTypeList.SelectedValue);
                bilCollectioninfo.InstNumber       = InstrumentNo.Text;
                bilCollectioninfo.InstDate         = creationTime.ToString("MM/dd/yyyy");
                bilCollectioninfo.CollAmount       = Convert.ToDecimal(InstrumentAmount.Text);
                bilCollectioninfo.CollStatus       = MtbBillCollection.Global.Definitions.CollectionStatus.Value.Received;

                if (bilCollectioninfo.InstTypeId != MtbBillCollection.Global.Definitions.InstType.Value.CASH)
                {
                    bilCollectioninfo.InstBankCode = Convert.ToInt32(InstrumentBankList.SelectedValue);
                }
                else
                {
                    bilCollectioninfo.InstBankCode = 0;
                }



                bilCollectioninfo.Remarks = txtRemarks.Text;



                try
                {
                    if (_saveMode == true)
                    {
                        bilCollectioninfo.InstRecvdBy = Convert.ToInt32(Session[MtbBillCollection.Global.Definitions.SessionVariable.Value.UserId].ToString());
                        _bilCollectionManager.SaveCollectionInformation(bilCollectioninfo);
                        ShowPopup(true, false, "");
                    }
                    else
                    {
                        bilCollectioninfo.ColectionId = Convert.ToInt32(ViewState[MtbBillCollection.Global.Definitions.SessionVariable.Value.CollectionId].ToString());
                        _bilCollectionManager.UpdateCollectionInformation(bilCollectioninfo);
                        ShowPopup(true, false, "");
                        Response.Redirect(Request.QueryString[MtbBillCollection.Global.Definitions.SessionVariable.Value.PreviousPage].ToString() + "?ClientId=" + ViewState[MtbBillCollection.Global.Definitions.SessionVariable.Value.ClientId].ToString());
                    }

                    initializeFields();
                }
                catch (Exception exception)
                {
                    ShowPopup(false, false, "");
                }
            }
        }
示例#7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session[MtbBillCollection.Global.Definitions.SessionVariable.Value.IsLoggedIn] == null || Convert.ToBoolean(Session[MtbBillCollection.Global.Definitions.SessionVariable.Value.IsLoggedIn]) == false ||
                (MtbBillCollection.Utility.Screen.IsUserPermitedToAccessScreen(Convert.ToInt32(Session[MtbBillCollection.Global.Definitions.SessionVariable.Value.UserTypeId].ToString()), "BillCollection")) == false)
            {
                Response.Redirect("/Default.aspx");
            }

            if (!Page.IsPostBack)
            {
                ClientList.DataSource = _bilCollectionManager.GetClientist();
                ClientList.DataBind();

                if (Request.QueryString.Count > 0)
                {
                    _clientid = Server.HtmlDecode(Request.QueryString[MtbBillCollection.Global.Definitions.SessionVariable.Value.ClientId].ToString());
                    ClientList.SelectedValue = _clientid;
                    //lblClient.Text = ClientList.SelectedItem.Text;
                    ViewState.Add(MtbBillCollection.Global.Definitions.SessionVariable.Value.ClientId, _clientid);
                }
                else
                {
                    if (ClientList.Items.Count > 0)
                    {
                        ClientList.SelectedIndex = 0;
                        //lblClient.Text = ClientList.Text;
                        _clientid = ClientList.Items[0].Value;
                    }
                }

                InstrumentDate.Text = DateTime.Now.Date.ToString("dd-MM-yyyy");
                //lblCollectionDateValue.Text = DateTime.Now.Date.ToString("dd/MMM/yyyy");
                //Date.Text = DateTime.Now.ToString("dd-MMM-yyyy");
                if (_clientid != "-1")
                {
                    ProductList.DataSource = _bilCollectionManager.GetProductList(Convert.ToInt32(_clientid));
                    ProductList.DataBind();
                    CollectionTypeList.DataSource = _bilCollectionManager.GetCollectionTypeList(Convert.ToInt32(_clientid));
                    CollectionTypeList.DataBind();
                    TranssactionTypeList.DataSource = _bilCollectionManager.GetTransactionTypeList(Convert.ToInt32(_clientid), Convert.ToInt32(ProductList.Items[0].Value));
                    TranssactionTypeList.DataBind();
                }
                //else
                //{
                //    ProductList.DataSource = _bilCollectionManager.GetProductList(Convert.ToInt32(ClientList.Items[0].Value));
                //    ProductList.DataBind();
                //    CollectionTypeList.DataSource = _bilCollectionManager.GetCollectionTypeList(Convert.ToInt32(ClientList.Items[0].Value));
                //    CollectionTypeList.DataBind();
                //    TranssactionTypeList.DataSource = _bilCollectionManager.GetTransactionTypeList(Convert.ToInt32(ClientList.Items[0].Value), Convert.ToInt32(ProductList.Items[0].Value));
                //    TranssactionTypeList.DataBind();
                //    TranssactionTypeList.SelectedIndex = (TranssactionTypeList.Items.Count > 0) ? 0 : -1;
                //}

                InstrumentBankList.DataSource = _bilCollectionManager.GetBankList();
                InstrumentBankList.DataBind();


                ProductTypeSelectedIndexChanged();
                if (Request.QueryString.Count > 1)
                {
                    _collectionId             = Server.HtmlDecode(Request.QueryString[MtbBillCollection.Global.Definitions.SessionVariable.Value.CollectionId].ToString());
                    _billCollectionInfo       = _bilCollectionManager.GetCollectionInformtion(_collectionId);
                    ProductList.SelectedValue = _billCollectionInfo.ProductId.ToString();
                    ProductTypeSelectedIndexChanged();
                    CollectionTypeList.SelectedValue = _billCollectionInfo.CollectionTypeId.ToString();
                    CollectionFrom.Text = _billCollectionInfo.CollFrom;
                    TranssactionTypeList.SelectedValue = _billCollectionInfo.InstTypeId.ToString();
                    InstrumentNo.Text   = _billCollectionInfo.InstNumber;
                    InstrumentDate.Text = _billCollectionInfo.InstDate;
                    string[] amnt = null;
                    amnt = _billCollectionInfo.CollAmount.ToString().Split('.');
                    if (amnt.Length > 0)
                    {
                        InstrumentAmount.Text = amnt[0];
                        if (amnt.Length == 2)
                        {
                            InstrumentAmount.Text += "." + amnt[1].Substring(0, 2);
                        }
                    }

                    InstrumentBankList.SelectedValue = _billCollectionInfo.InstBankCode.ToString();
                    txtRemarks.Text = _billCollectionInfo.Remarks;
                    //SaveButton.Text = "Update";
                    _previousPage = this.PreviousPage;
                    _saveMode     = false;
                    ViewState.Add(MtbBillCollection.Global.Definitions.SessionVariable.Value.SaveMode, _saveMode);
                    ViewState.Add(MtbBillCollection.Global.Definitions.SessionVariable.Value.CollectionId, _collectionId);
                }
                else
                {
                    CollectionFrom.Focus();
                    initializeFields();
                }
                //TranssactionTypeList.Attributes.Add("onchange", "ShowData()");
            }
            else
            {
                ProductList.Enabled          = true;
                TranssactionTypeList.Enabled = true;

                InstrumentAmount.Enabled   = true;
                InstrumentBankList.Enabled = true;
            }
            EnableOrDisableInstrumentFields();
        }