示例#1
0
    public static bool InsertandUpdateFund(string FundId, string FundName, string FundType, string customerCode, string boId, string sellbuycommision, string CompanyCode, string fundClose)
    {
        CommonGateway commonGatewayObj = new CommonGateway();
        DataTable     dtgetfund;

        if (FundId != "")
        {
            string strfundcode = "SELECT  *  FROM    FUND WHERE    BOID IS NOT NULL  and f_cd = " + FundId + "";
            dtgetfund = commonGatewayObj.Select(strfundcode);
            if (dtgetfund != null && dtgetfund.Rows.Count > 0)
            {
                string strUPQuery = "update FUND set F_NAME='" + FundName + "',COMP_CD ='" + CompanyCode + "',F_TYPE ='" + FundType + "',IS_F_CLOSE='" + fundClose + "',CUSTOMER ='" + customerCode + "',BOID ='" + boId + "',SL_BUY_COM_PCT ='" + sellbuycommision + "' where F_CD =" + FundId + "";

                int NumOfRows = commonGatewayObj.ExecuteNonQuery(strUPQuery);
            }
            else
            {
                string strInsQuery;

                strInsQuery = "insert into Fund(F_CD,F_NAME,COMP_CD,F_TYPE,IS_F_CLOSE,CUSTOMER,BOID,SL_BUY_COM_PCT)values('" + FundId + "','" + FundName + "','" + CompanyCode + "','" + FundType + "','" + fundClose + "','" + customerCode + "','" + boId + "','" + sellbuycommision + "')";

                int NumOfRows = commonGatewayObj.ExecuteNonQuery(strInsQuery);
            }
        }

        return(true);
    }
示例#2
0
    protected void avgPriceButton_Click(object sender, EventArgs e)
    {
        try
        {
            StringBuilder sbQueryInsert = new StringBuilder();
            commonGatewayObj.BeginTransaction();

            if (!pfolioBLObj.getMPUpdateStatus(marketPriceDateTextBox.Text.ToString(), "AVERAGE"))
            {
                commonGatewayObj.ExecuteNonQuery("UPDATE COMP SET ADC_RT=ROUND((NVL(AVG_RT,CSE_RT)+NVL(CSE_RT,AVG_RT))/2,2)  WHERE RT_UPD_DT='" + marketPriceDateTextBox.Text.ToString() + "'");
                sbQueryInsert.Append(" INSERT INTO MARKET_PRICE SELECT COMP_CD,'" + marketPriceDateTextBox.Text.ToString() + "' AS EXPR1, ADC_RT, AVG_RT, CSE_RT, ");
                sbQueryInsert.Append(" DECODE(CSE_DT, NULL, NULL, '" + marketPriceDateTextBox.Text.ToString() + "') AS EXPR2, DSE_HIGH, DSE_LOW, DSE_OPEN  FROM  COMP WHERE  VALID IS NULL ");
                commonGatewayObj.ExecuteNonQuery(sbQueryInsert.ToString());

                commonGatewayObj.CommitTransaction();
                avegLabel.Text = "Price  Average Successfully";
                avegLabel.Style.Add("color", "#009933");
            }
            else
            {
                avegLabel.Text = "Price Already Avaraged On That Date";
                avegLabel.Style.Add("color", "red");
            }
        }
        catch (Exception ex)
        {
            commonGatewayObj.RollbackTransaction();
            avegLabel.Text = "Price  Average failed Error:" + ex.Message.ToString();
            avegLabel.Style.Add("color", "red");
        }
    }
    protected void DeleteButton_Click(object sender, EventArgs e)
    {
        UnitHolderRegistration regObj = new UnitHolderRegistration();

        regObj.FundCode   = fundCodeDDL.SelectedValue.ToString();
        regObj.BranchCode = branchCodeDDL.SelectedValue.ToString();
        Hashtable htUpdateMoneyReceipt = new Hashtable();

        try
        {
            commonGatewayObj.BeginTransaction();
            StringBuilder sbQuery = new StringBuilder();
            sbQuery.Append("UPDATE MONEY_RECEIPT SET VALID='N' , RECEIPT_EDIT_TYPE='D' , RECEIPT_EDIT_BY='" + userObj.UserID.ToString() + "',");
            sbQuery.Append(" RECEIPT_EDIT_DATE='" + DateTime.Today.ToString("dd-MMM-yyyy") + "'  WHERE ID=" + moneyReceipDropDownList.SelectedValue.ToString());
            commonGatewayObj.ExecuteNonQuery(sbQuery.ToString());
            commonGatewayObj.CommitTransaction();
            ClearText();

            moneyReceipDropDownList.DataSource     = unitSaleBLObj.dtMoneyRecieptforDDL(" AND REG_BK = '" + regObj.FundCode.ToString().ToUpper() + "' AND REG_BR = '" + regObj.BranchCode.ToString().ToUpper() + "'AND RECEIPT_TYPE = 'REP' AND SL_REP_TR_RN_NO IS NULL  AND VALID IS NULL AND ACC_VOUCHER_NO IS NULL ORDER BY RECEIPT_NO DESC ");
            moneyReceipDropDownList.DataTextField  = "RECEIPT_NO";
            moneyReceipDropDownList.DataValueField = "ID";
            moneyReceipDropDownList.DataBind();
            ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "alert('Delete Success');", true);
        }

        catch (Exception ex)
        {
            commonGatewayObj.RollbackTransaction();

            ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "alert('Delete Failed');", true);
        }
    }
    protected void saveButton_Click(object sender, EventArgs e)
    {
        Session["MenUList"]       = SelectUser();
        Session["UserIdSelected"] = userDropDownList.SelectedItem.Text.ToString();
        string    menuIDs = "";
        string    UserId  = "";
        string    strInsQuery;
        DataTable dtmenuExist;

        menuIDs = (string)Session["MenUList"];
        UserId  = (string)Session["UserIdSelected"];

        if (string.IsNullOrEmpty(Session["MenUList"] as string))
        {
            ClientScript.RegisterStartupScript(this.GetType(), "Popup", "alert('Please check mark at least one Menu');", true);
            dvGridFund.Visible = true;
        }
        else
        {
            List <string> menuList = menuIDs.Split(new char[] { ',' }).ToList();

            foreach (var menuid in menuList)
            {
                string strMenuExits = "SELECT  *  FROM    MENUPERMISSIONS WHERE    MENU_ID= " + menuid + "   and USER_ID = '" + UserId + "'";
                dtmenuExist = commonGatewayObj.Select(strMenuExits);



                if (dtmenuExist != null && dtmenuExist.Rows.Count > 0)
                {
                    string strUPQuery = "update MENUPERMISSIONS set MENU_ID='" + menuid + "' where USER_ID ='" + UserId + "' and MENU_ID='" + menuid + "'";

                    int upNumOfRows = commonGatewayObj.ExecuteNonQuery(strUPQuery);
                }
                else
                {
                    strInsQuery = "insert into MENUPERMISSIONS(MENU_ID,USER_ID)values('" + menuid + "','" + UserId + "')";

                    int inNumOfRows = commonGatewayObj.ExecuteNonQuery(strInsQuery);
                }
            }

            Response.Redirect("MenuPermissionForUser.aspx");
        }
    }
示例#5
0
    protected void grdShowDSEMP_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        GridViewRow row = (GridViewRow)grdShowDSEMP.Rows[e.RowIndex];


        string childOfsubmenuId = row.Cells[4].Text;
        string userId           = row.Cells[0].Text;


        string strDelQuery = "delete from MENUPERMISSIONS where MENU_ID='" + childOfsubmenuId + "' and USER_ID='" + userId + "'";
        int    NumOfRows   = commonGatewayObj.ExecuteNonQuery(strDelQuery);

        BindGrid();
    }
    protected void OnRowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        //  GridViewRow row = GridViewNonListedSecurities.Rows[e.NewSelectedIndex];
        lblProcessing.Text = "";
        string confirmValue = HiddenField2.Value;

        if (confirmValue == "Yes")
        {
            GridViewRow row = (GridViewRow)GridViewNonListedSecurities.Rows[e.RowIndex];

            string companyCode = row.Cells[1].Text.ToString();
            string fCd         = row.Cells[0].Text.ToString();

            double amount = Convert.ToDouble(row.Cells[3].Text.ToString());

            string strQuery1 = "Select  TO_CHAR(max(INV_DATE), 'DD-MON-YYYY')INV_DATE  from NON_LISTED_SECURITIES where F_CD=" + fCd + "";

            DataTable dtNonListedDetailsMAXInV_DATE = commonGatewayObj.Select(strQuery1);

            string maxInvDate = dtNonListedDetailsMAXInV_DATE.Rows[0]["INV_DATE"].ToString();



            string strQuery2 = "Select  * from NON_LISTED_SECURITIES where F_CD=" + fCd + " and INV_DATE='" + maxInvDate + "' ";

            DataTable dtNonlistedSecuritiesMaxInvDate = commonGatewayObj.Select(strQuery2);

            if (dtNonlistedSecuritiesMaxInvDate.Rows.Count > 0)
            {
                Double FinalAmount = Convert.ToDouble(dtNonlistedSecuritiesMaxInvDate.Rows[0]["INV_AMOUNT"].ToString()) - amount;

                if (FinalAmount >= 0)
                {
                    string strUpdateNonlisted = "UPDATE NON_LISTED_SECURITIES SET INV_AMOUNT = '" + Convert.ToDouble(FinalAmount) + "' WHERE F_CD = " + fCd + " and INV_DATE ='" + maxInvDate + "'";

                    int NumOfRows2 = commonGatewayObj.ExecuteNonQuery(strUpdateNonlisted);
                }
                string strDelQuery = "delete from NON_LISTED_SECURITIES_DETAILS where comp_cd='" + companyCode + "' and f_cd=" + fCd + " and AMOUNT=" + amount + "";
                int    NumOfRows   = commonGatewayObj.ExecuteNonQuery(strDelQuery);
                FillNonListedSecuritiesGrid();
            }
        }
        else
        {
            lblProcessing.Text = "Delete  unsuccessful";
        }
    }
    public string UpdateAmmountInNonlisted(string FundId, string Date, string Ammount)
    {
        CommonGateway commonGatewayObj = new CommonGateway();

        string strUpdateNonlisted = "";
        string message            = "";

        if (FundId != "")
        {
            strUpdateNonlisted = "UPDATE NON_LISTED_SECURITIES SET INV_AMOUNT = '" + Convert.ToDouble(Ammount) + "' WHERE F_CD = " + FundId + " and INV_DATE ='" + Date + "'";

            int NumOfRows = commonGatewayObj.ExecuteNonQuery(strUpdateNonlisted);
            if (NumOfRows > 0)
            {
                message = "Data Updated Successfully !!!";
            }
        }

        return(message);
    }
    public static bool InsertandUpdateUser(string userId, string Password, string confirmPassword)
    {
        CommonGateway commonGatewayObj = new CommonGateway();
        DataTable     dtgetUser;
        string        passWord = "";

        if (userId != "")
        {
            string strUserID = "select * from user_table where user_id='" + userId + "'";
            dtgetUser = commonGatewayObj.Select(strUserID);
            if (dtgetUser != null && dtgetUser.Rows.Count > 0)
            {
                string EncryptionKey = "MAKV2SPBNI99212";
                byte[] clearBytes    = Encoding.Unicode.GetBytes(Password);
                using (Aes encryptor = Aes.Create())
                {
                    Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(EncryptionKey, new byte[] { 0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76 });
                    encryptor.Key = pdb.GetBytes(32);
                    encryptor.IV  = pdb.GetBytes(16);
                    using (MemoryStream ms = new MemoryStream())
                    {
                        using (CryptoStream cs = new CryptoStream(ms, encryptor.CreateEncryptor(), CryptoStreamMode.Write))
                        {
                            cs.Write(clearBytes, 0, clearBytes.Length);
                            cs.Close();
                        }
                        passWord = Convert.ToBase64String(ms.ToArray());
                    }
                }

                string strUPQuery = "update USER_TABLE set PASSWORD ='******' where USER_ID ='" + userId + "'";

                int NumOfRows = commonGatewayObj.ExecuteNonQuery(strUPQuery);
            }
        }

        return(true);
    }
示例#9
0
    protected void ButtonRoleAddTextBox_Click(object sender, EventArgs e)
    {
        string    roleName   = UserRoleTextBox.Text.ToString();
        DataTable dtRoleList = new DataTable();

        StringBuilder sbMst     = new StringBuilder();
        StringBuilder sbOrderBy = new StringBuilder();

        sbOrderBy.Append("");

        sbMst.Append(" select * from USER_ROLE where ROLE_NAME='" + roleName + "' ");
        sbOrderBy.Append(" order by USER_ROLE.ROLE_ID  ");
        sbMst.Append(sbOrderBy.ToString());

        dtRoleList = commonGatewayObj.Select(sbMst.ToString());

        if (dtRoleList.Rows.Count > 0)
        {
            lblProcessing.Text = "This role already assigned";
        }
        else
        {
            DataTable dtRoleId = new DataTable();
            string    strInsQuery;

            string strQuery = "select max(ROLE_ID)+1 as ROLE_ID from  USER_ROLE";
            dtRoleId = commonGatewayObj.Select(strQuery);

            if (dtRoleId.Rows.Count > 0)
            {
                strInsQuery = "insert into USER_ROLE(ROLE_ID,ROLE_NAME)values(" + dtRoleId.Rows[0]["ROLE_ID"].ToString() + ",'" + roleName + "')";
                int NumOfRows = commonGatewayObj.ExecuteNonQuery(strInsQuery);
                lblProcessing.Text = "This role sucessfully inserted";
            }
        }
    }
示例#10
0
        public void SaveSaleEditInfoCDS(UnitHolderRegistration unitRegObj, UnitSale unitSaleObj, UnitUser unitUserObj)
        {
            Hashtable     htUnitSale     = new Hashtable();
            Hashtable     htUnitSaleCert = new Hashtable();
            StringBuilder sbQuery        = new StringBuilder();

            try
            {
                commonGatewayObj.BeginTransaction();



                htUnitSale.Add("SL_DT", Convert.ToDateTime(unitSaleObj.SaleDate).ToString("dd-MMM-yyyy"));
                htUnitSale.Add("SL_PRICE", Convert.ToDecimal(unitSaleObj.SaleRate.ToString()));
                htUnitSale.Add("QTY", Convert.ToInt32(unitSaleObj.SaleUnitQty.ToString()));
                htUnitSale.Add("SL_TYPE", unitSaleObj.SaleType.ToString().ToUpper());



                if (!(unitSaleObj.MoneyReceiptNo.ToString() == "0"))
                {
                    htUnitSale.Add("MONY_RECT_NO", Convert.ToInt32(unitSaleObj.MoneyReceiptNo));
                }
                else
                {
                    htUnitSale.Add("MONY_RECT_NO", DBNull.Value);
                }

                if (!((unitSaleObj.MoneyReceiptNo.ToString() == "0") && unitSaleObj.PaymentType.ToString() == "CHQ" && unitSaleObj.ChequeNo == null && unitSaleObj.ChequeDate == null))
                {
                    htUnitSale.Add("PAY_TYPE", unitSaleObj.PaymentType);
                }
                else
                {
                    htUnitSale.Add("PAY_TYPE", DBNull.Value);
                }

                if (unitSaleObj.ChequeNo != null)
                {
                    htUnitSale.Add("CHQ_DD_NO", unitSaleObj.ChequeNo);
                }
                else
                {
                    htUnitSale.Add("CHQ_DD_NO", DBNull.Value);
                }
                if (unitSaleObj.ChequeDate == null)
                {
                    htUnitSale.Add("CHEQUE_DT", DBNull.Value);
                }
                else
                {
                    htUnitSale.Add("CHEQUE_DT", unitSaleObj.ChequeDate);
                }
                if (!(unitSaleObj.BankCode.ToString() == "0"))
                {
                    htUnitSale.Add("BANK_CODE", Convert.ToInt16(unitSaleObj.BankCode));
                }
                else
                {
                    htUnitSale.Add("BANK_CODE", DBNull.Value);
                }
                if (!(unitSaleObj.BranchCode.ToString() == "0"))
                {
                    htUnitSale.Add("BRANCH_CODE", Convert.ToInt16(unitSaleObj.BranchCode));
                }
                else
                {
                    htUnitSale.Add("BRANCH_CODE", DBNull.Value);
                }

                if (!(unitSaleObj.CashAmount.ToString() == "0"))
                {
                    htUnitSale.Add("CASH_AMT", Convert.ToDecimal(unitSaleObj.CashAmount));
                }
                else
                {
                    htUnitSale.Add("CASH_AMT", DBNull.Value);
                }
                if (unitSaleObj.MultiPayType != null)
                {
                    htUnitSale.Add("MULTI_PAY_REMARKS", unitSaleObj.MultiPayType);
                }
                else
                {
                    htUnitSale.Add("MULTI_PAY_REMARKS", DBNull.Value);
                }



                commonGatewayObj.Update(htUnitSale, "SALE", "SL_NO=" + Convert.ToInt32(unitSaleObj.SaleNo.ToString()) + " AND REG_BK='" + unitRegObj.FundCode.ToString().ToUpper() + "' AND REG_BR='" + unitRegObj.BranchCode.ToString() + "' ");

                sbQuery.Append(" INSERT INTO  SALE_ED_INFO ( SL_NO, SL_DT, REG_BK, REG_BR, REG_NO, SL_PRICE, QTY, SL_TYPE, VALID, MONY_RECT_NO, PAY_TYPE, CHQ_DD_NO, ");
                sbQuery.Append(" CASH_AMT, BANK_CODE, BRANCH_CODE, MULTI_PAY_REMARKS, CHEQUE_DT,USER_NM, EDIT_TYPE, ENT_DT ) ");
                sbQuery.Append(" SELECT SL_NO, SL_DT, REG_BK, REG_BR, REG_NO, SL_PRICE, QTY, SL_TYPE, VALID, MONY_RECT_NO, PAY_TYPE, CHQ_DD_NO, CASH_AMT, BANK_CODE, BRANCH_CODE, MULTI_PAY_REMARKS, CHEQUE_DT, ");
                sbQuery.Append(" '" + unitUserObj.UserID + "' USER_NM,'E' EDIT_TYPE ,'" + DateTime.Now.ToString("dd-MMM-yyyy") + "'  ENT_DT  FROM  SALE ");
                sbQuery.Append(" WHERE SL_NO=" + Convert.ToInt32(unitSaleObj.SaleNo.ToString()) + " AND REG_BK='" + unitRegObj.FundCode.ToString().ToUpper() + "' AND REG_BR='" + unitRegObj.BranchCode.ToString() + "' AND REG_NO=" + Convert.ToInt32(unitRegObj.RegNumber));
                commonGatewayObj.ExecuteNonQuery(sbQuery.ToString());

                commonGatewayObj.CommitTransaction();
            }
            catch (Exception ex)
            {
                commonGatewayObj.RollbackTransaction();
                throw ex;
            }
        }
示例#11
0
    public void SaveAccountVoucherWithChequePayment(string accountSchema)
    {
        try
        {
            int  countCheck   = 0;
            long tranNumber   = commonGatewayObj.GetMaxNo(accountSchema + ".GL_BASICINFO", "TRAN_ID");
            long contrlNumber = commonGatewayObj.GetMaxNo(accountSchema + ".GL_BASICINFO", "TO_NUMBER(CTRLNO)") - 1;

            string acc_op_id       = unitRepBLObj.getAcc_OP_ID(fundNameDropDownList.SelectedValue.ToString());
            long   acc_terminal_no = unitRepBLObj.getAcc_terminal_no(fundNameDropDownList.SelectedValue.ToString());

            int       faceValue           = unitRepBLObj.getUnitFaceValue(fundNameDropDownList.SelectedValue.ToString());
            string    bankPaymentCode     = unitRepBLObj.getUnitBankPaymentCode(fundNameDropDownList.SelectedValue.ToString());
            string    getUnitFundBankCode = unitRepBLObj.getUnitFundBankCode(fundNameDropDownList.SelectedValue.ToString());
            Hashtable htInsert            = new Hashtable();
            Hashtable htUpdate            = new Hashtable();
            commonGatewayObj.BeginTransaction();
            DataTable dtFundYearEndInfo = commonGatewayObj.Select("SELECT * FROM FUND_INFO WHERE FUND_CD='" + fundNameDropDownList.SelectedValue.ToString() + "'");
            int       year          = Convert.ToDateTime(TranDateTextBox.Text.ToString()).Year;
            int       month         = Convert.ToDateTime(TranDateTextBox.Text.ToString()).Month;
            string    yearStartDate = dtFundYearEndInfo.Rows[0]["YEAR_START_MONTH"].ToString();
            string    yearEndDate   = dtFundYearEndInfo.Rows[0]["YEAR_END_MONTH"].ToString();
            if (yearStartDate == "01-JUL")
            {
                if (month < 6)
                {
                    yearEndDate = yearEndDate + "-" + year.ToString();
                    year--;
                    yearStartDate = yearStartDate + "-" + year.ToString();
                }
                else
                {
                    yearStartDate = yearStartDate + "-" + year.ToString();
                    year++;
                    yearEndDate = yearEndDate + "-" + year.ToString();
                }
            }
            else
            {
                yearStartDate = yearStartDate + "-" + year.ToString();
                yearEndDate   = yearEndDate + "-" + year.ToString();
            }
            if (unitRepBLObj.IsDuplicateAccVoucherNo(accountSchema, VoucherNoTexBox.Text.Trim(), "1", yearStartDate, yearEndDate))
            {
                ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "alert('Save Failed Duplicate Payment Voucher Number');", true);
            }
            else
            {
                foreach (GridViewRow Drv in SurrenderListGridView.Rows)
                {
                    CheckBox leftCheckBox = (CheckBox)SurrenderListGridView.Rows[countCheck].FindControl("leftCheckBox");
                    //TextBox VoucherNoTexBox = (TextBox)SurrenderListGridView.Rows[countCheck].FindControl("VoucherNumberTextBox");
                    TextBox ChequeNoTexBox = (TextBox)SurrenderListGridView.Rows[countCheck].FindControl("ChequeNumberTextBox");

                    if (leftCheckBox.Checked)
                    {
                        decimal unitFaceValue      = Convert.ToDecimal(faceValue);
                        decimal unitSaleQty        = Convert.ToDecimal(Drv.Cells[8].Text.ToString());
                        decimal unitSaleRate       = Convert.ToDecimal(Drv.Cells[9].Text.ToString());
                        decimal unitSaleTotalValue = Convert.ToDecimal(Drv.Cells[10].Text.ToString());

                        DataTable dtHolderBankInfo = unitRepBLObj.dtGetHolderBankInfo(Drv.Cells[2].Text.ToUpper().ToString(), Drv.Cells[3].Text.ToUpper().ToString(), Convert.ToInt32(Drv.Cells[4].Text.ToString()));


                        htUpdate = new Hashtable();
                        if (dtHolderBankInfo.Rows.Count > 0)
                        {
                            htUpdate.Add("HOLDER_AC_NO", dtHolderBankInfo.Rows[0]["BK_AC_NO"].ToString());
                            htUpdate.Add("HOLDER_ROUTING_NO", dtHolderBankInfo.Rows[0]["ROUTING_NO"].ToString());
                        }
                        htUpdate.Add("CHEQUE_DATE", ChequeDateTextBox.Text.ToString());
                        htUpdate.Add("CHEQUE_POSTED_BY", userObj.UserID.ToString());
                        htUpdate.Add("CHEQUE_POSTED_DATE", DateTime.Now.ToString());
                        htUpdate.Add("VOUCHER_NO", VoucherNoTexBox.Text.Trim().ToString());
                        htUpdate.Add("CHEQUE_NO", ChequeNoTexBox.Text.Trim().ToString());
                        if (unitRepBLObj.IsValidMobileNumber(regObj))
                        {
                            htUpdate.Add("SMS_CREATE_DATE", DateTime.Now.ToString());
                        }


                        htUpdate.Add("SIGNATORY1_ID", Signatory1DropDownList.SelectedValue.ToUpper().ToString());
                        htUpdate.Add("SIGANTORY2_ID", Signatory2DropDownList.SelectedValue.ToUpper().ToString());
                        htUpdate.Add("FUND_INFO_BANK_CODE", getUnitFundBankCode);

                        commonGatewayObj.Update(htUpdate, "REPURCHASE ", "REG_BK='" + Drv.Cells[2].Text.ToUpper().ToString() + "' AND REG_BR='" + Drv.Cells[3].Text.ToUpper().ToString() + "' AND REG_NO=" + Convert.ToInt32(Drv.Cells[4].Text.ToString()) + " AND REP_NO=" + Convert.ToInt32(Drv.Cells[5].Text.ToString()));
                        contrlNumber++;
                        htInsert = new Hashtable();
                        htInsert.Add("TRAN_ID", tranNumber + 1);
                        htInsert.Add("ACCCODE", "101010000");
                        htInsert.Add("BANKACNO", "101010000");
                        htInsert.Add("TRAN_TIME", DateTime.Now.ToShortTimeString());
                        htInsert.Add("TRAN_DATE", TranDateTextBox.Text.Trim());
                        htInsert.Add("REMARKS", unitSaleQty.ToString() + " unit surrendered @tk." + unitSaleRate.ToString() + " per unit ");
                        htInsert.Add("TRAN_TYPE", "D");
                        htInsert.Add("VOUCHER_NO", VoucherNoTexBox.Text.Trim().ToString());
                        htInsert.Add("TOTAL_AMNT", Convert.ToDecimal(unitFaceValue * unitSaleQty));
                        htInsert.Add("CTRLNO", contrlNumber);
                        htInsert.Add("OP_ID", userObj.UserID.ToString());
                        htInsert.Add("VOUCHER_TYPE", "1");
                        htInsert.Add("TERMINAL_NO", acc_terminal_no);
                        htInsert.Add("RECENT", "y");
                        htInsert.Add("LATESTDEL", "m");
                        htInsert.Add("ISOUT", "N");
                        htInsert.Add("ISREV", "N");
                        htInsert.Add("OLDDATA", "N");


                        commonGatewayObj.Insert(htInsert, accountSchema + ".GL_TRAN");

                        if (unitSaleRate < unitFaceValue)
                        {
                            contrlNumber++;

                            htInsert = new Hashtable();
                            htInsert.Add("TRAN_ID", tranNumber + 1);
                            htInsert.Add("ACCCODE", "101020000");
                            htInsert.Add("BANKACNO_CONTRA", "101020000");
                            htInsert.Add("TRAN_TIME", DateTime.Now.ToShortTimeString());
                            htInsert.Add("TRAN_DATE", TranDateTextBox.Text.Trim());
                            htInsert.Add("REMARKS", unitSaleQty.ToString() + " unit surrendered @tk." + unitSaleRate.ToString() + " per unit ");
                            htInsert.Add("TRAN_TYPE", "C");
                            htInsert.Add("VOUCHER_NO", VoucherNoTexBox.Text.Trim().ToString());
                            htInsert.Add("TOTAL_AMNT", Convert.ToDecimal((unitFaceValue * unitSaleQty) - unitSaleTotalValue));
                            htInsert.Add("CTRLNO", contrlNumber);
                            htInsert.Add("OP_ID", userObj.UserID.ToString());
                            htInsert.Add("VOUCHER_TYPE", "1");
                            htInsert.Add("TERMINAL_NO", acc_terminal_no);
                            htInsert.Add("RECENT", "y");
                            htInsert.Add("LATESTDEL", "m");
                            htInsert.Add("ISOUT", "N");
                            htInsert.Add("ISREV", "N");
                            htInsert.Add("OLDDATA", "N");
                            commonGatewayObj.Insert(htInsert, accountSchema + ".GL_TRAN");
                        }
                        else if (unitSaleRate > unitFaceValue)
                        {
                            contrlNumber++;
                            htInsert = new Hashtable();
                            htInsert.Add("TRAN_ID", tranNumber + 1);
                            htInsert.Add("ACCCODE", "101020000");
                            htInsert.Add("BANKACNO", "101020000");
                            htInsert.Add("TRAN_TIME", DateTime.Now.ToShortTimeString());
                            htInsert.Add("TRAN_DATE", TranDateTextBox.Text.Trim());
                            htInsert.Add("REMARKS", unitSaleQty.ToString() + " unit surrendered @tk." + unitSaleRate.ToString() + " per unit ");
                            htInsert.Add("TRAN_TYPE", "D");
                            htInsert.Add("VOUCHER_NO", VoucherNoTexBox.Text.Trim().ToString());
                            htInsert.Add("TOTAL_AMNT", Convert.ToDecimal(unitSaleTotalValue - ((unitFaceValue * unitSaleQty))));
                            htInsert.Add("CTRLNO", contrlNumber);
                            htInsert.Add("OP_ID", userObj.UserID.ToString());
                            htInsert.Add("VOUCHER_TYPE", "1");
                            htInsert.Add("TERMINAL_NO", acc_terminal_no);
                            htInsert.Add("RECENT", "y");
                            htInsert.Add("LATESTDEL", "m");
                            htInsert.Add("ISOUT", "N");
                            htInsert.Add("ISREV", "N");
                            htInsert.Add("OLDDATA", "N");
                            commonGatewayObj.Insert(htInsert, accountSchema + ".GL_TRAN");
                        }
                        contrlNumber++;
                        htInsert = new Hashtable();
                        htInsert.Add("TRAN_ID", tranNumber + 1);
                        htInsert.Add("ACCCODE", bankPaymentCode);
                        htInsert.Add("BANKACNO_CONTRA", bankPaymentCode);
                        htInsert.Add("TRAN_TIME", DateTime.Now.ToShortTimeString());
                        htInsert.Add("TRAN_DATE", TranDateTextBox.Text.Trim());
                        htInsert.Add("REMARKS", unitSaleQty.ToString() + " unit surrendered @tk." + unitSaleRate.ToString() + " per unit ");
                        htInsert.Add("TRAN_TYPE", "C");
                        htInsert.Add("VOUCHER_NO", VoucherNoTexBox.Text.Trim().ToString());
                        htInsert.Add("TOTAL_AMNT", Convert.ToDecimal(unitSaleTotalValue));
                        htInsert.Add("CTRLNO", contrlNumber);
                        htInsert.Add("OP_ID", userObj.UserID.ToString());
                        htInsert.Add("VOUCHER_TYPE", "1");
                        htInsert.Add("CHEQUENO", ChequeNoTexBox.Text.Trim().ToString());
                        htInsert.Add("CHEQUE_DATE", ChequeDateTextBox.Text.Trim());
                        htInsert.Add("TERMINAL_NO", acc_terminal_no);
                        htInsert.Add("RECENT", "y");
                        htInsert.Add("LATESTDEL", "m");
                        htInsert.Add("ISOUT", "N");
                        htInsert.Add("ISREV", "N");
                        htInsert.Add("OLDDATA", "N");
                        commonGatewayObj.Insert(htInsert, accountSchema + ".GL_TRAN");
                    }

                    countCheck++;
                }

                contrlNumber++;
                tranNumber++;
                commonGatewayObj.ExecuteNonQuery(" UPDATE " + accountSchema + ".GL_BASICINFO SET TRAN_ID=" + tranNumber + " , CTRLNO='" + contrlNumber + "' WHERE 1=1");
                commonGatewayObj.CommitTransaction();
            }
        }
        catch (Exception ex)
        {
            commonGatewayObj.RollbackTransaction();
            throw ex;
        }
    }
    protected void saveButton_Click(object sender, EventArgs e)
    {
        string   LoginID     = Session["UserID"].ToString();
        string   LoginName   = Session["UserName"].ToString().ToUpper();
        string   record_date = recordDateTextBox.Text.ToString();
        string   recordate;
        DateTime?dtrecoddate;

        if (!string.IsNullOrEmpty(record_date))
        {
            dtrecoddate = Convert.ToDateTime(record_date);

            recordate = dtrecoddate.Value.ToString("dd-MMM-yyyy");
        }
        else
        {
            dtrecoddate = null;
            recordate   = "";
        }



        Hashtable httable = new Hashtable();

        httable.Add("VCH_DT", Convert.ToDateTime(howlaDateTextBox.Text.ToString()).ToString("dd-MMM-yyyy"));
        if (!stockExchangeDropDownList.SelectedValue.Equals("0"))
        {
            httable.Add("STOCK_EX", Convert.ToChar(stockExchangeDropDownList.SelectedValue));
        }
        if (!fundNameDropDownList.SelectedValue.Equals("0"))
        {
            httable.Add("F_CD", Convert.ToInt16(fundNameDropDownList.SelectedValue));
        }
        if (!companyNameDropDownList.SelectedValue.Equals("0"))
        {
            httable.Add("COMP_CD", Convert.ToInt16(companyNameDropDownList.SelectedValue));
        }
        if (!transTypeDropDownList.SelectedValue.Equals("0"))
        {
            httable.Add("TRAN_TP", Convert.ToChar(transTypeDropDownList.SelectedValue));
        }
        if (!noOfShareTextBox.Text.Equals(""))
        {
            httable.Add("NO_SHARE", Convert.ToDouble(noOfShareTextBox.Text));
        }
        if (!amountTextBox.Text.Equals(""))
        {
            httable.Add("AMOUNT", Convert.ToDouble(amountTextBox.Text));
        }
        if (!voucherNoTextBox.Text.Equals(""))
        {
            httable.Add("VCH_NO", (voucherNoTextBox.Text).ToString());
        }
        if (!rateTextBox.Text.Equals(""))
        {
            httable.Add("RATE", Convert.ToDouble(rateTextBox.Text));
        }
        if (!amountAfterComissionTextBox.Text.Equals(""))
        {
            httable.Add("AMT_AFT_COM", Convert.ToDouble(amountAfterComissionTextBox.Text));
        }



        //httable.Add("ENTRY_DATE", DateTime.Today.ToString("dd-MMM-yyyy"));
        httable.Add("OP_NAME", LoginID);

        if (pf1s1DAOObj.IsDuplicateBonusRightEntry(Convert.ToInt32(fundNameDropDownList.SelectedValue.ToString()), Convert.ToInt32(companyNameDropDownList.SelectedValue.ToString()), Convert.ToDateTime(howlaDateTextBox.Text.Trim().ToString()).ToString("dd-MMM-yyyy"), transTypeDropDownList.SelectedValue.ToString(), Convert.ToInt32(noOfShareTextBox.Text.Trim().ToString())))
        {
            ClientScript.RegisterStartupScript(this.GetType(), "Popup", "alert('Duplicate not allowed');", true);
        }
        else
        {
            if (transTypeDropDownList.SelectedValue == "B")
            {
                if (stockExchangeDropDownList.SelectedValue == "A")
                {
                    if (!recordate.Equals(""))
                    {
                        httable.Add("RECORD_DT", recordate);
                    }
                    string strQbooKCL = "SELECT COMP_CD, FY, RECORD_DT, BOOK_TO, BONUS, RIGHT_APPR_DT,  RIGHT, CASH, AGM, REMARKS, POSTED, PDATE,  ENTRY_DATE FROM BOOK_CL WHERE  COMP_CD=" + companyNameDropDownList.SelectedValue + " AND RECORD_DT='" + recordate + "'" + " and posted is null";

                    DataTable dtbookCl = commonGatewayObj.Select(strQbooKCL);
                    if (dtbookCl != null && dtbookCl.Rows.Count > 0)
                    {
                        string    strRecordateFT = "SELECT VCH_DT, F_CD, COMP_CD, TRAN_TP, VCH_NO, NO_SHARE, RATE, COST_RATE, CRT_AFT_COM,  AMOUNT, AMT_AFT_COM, STOCK_EX, OP_NAME, PVCH_NO, RECORD_DT FROM FUND_TRANS_HB Where  f_cd='" + fundNameDropDownList.SelectedValue.ToString() + "' AND comp_cd=" + companyNameDropDownList.SelectedValue.ToString() + " and RECORD_DT='" + recordate + "'";
                        DataTable dtRecorDateFT  = commonGatewayObj.Select(strRecordateFT);

                        if (dtRecorDateFT != null && dtRecorDateFT.Rows.Count > 0)
                        {
                            ClientScript.RegisterStartupScript(this.GetType(), "Popup", "alert('Bonus already posted.');", true);
                            ClearFields();
                        }
                        else
                        {
                            if (httable["TRAN_TP"].ToString() == "B")
                            {
                                commonGatewayObj.Insert(httable, "fund_trans_hb");
                                ClientScript.RegisterStartupScript(this.GetType(), "Popup", "alert('Saved Successfully');", true);
                            }
                        }
                    }
                    else
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "Popup", "alert('No data found in Book Closer Entry');", true);
                    }
                }
                else
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "Popup", "alert('Please Select Stock Exchange as ALL');", true);
                }
            }
            else if (transTypeDropDownList.SelectedValue == "I")
            {
                if (httable["TRAN_TP"].ToString() == "I")
                {
                    commonGatewayObj.Insert(httable, "fund_trans_hb");

                    string strupdateQueryAVgRateFromComp = "update comp set AVG_RT='" + Convert.ToDouble(rateTextBox.Text) + "',CSE_RT='" + Convert.ToDouble(rateTextBox.Text) + "',ADC_RT='" + Convert.ToDouble(rateTextBox.Text) + "' where comp_cd =" + companyNameDropDownList.SelectedValue.ToString() + "";

                    int updateQueryAVgRateFromCompNumOfRows = commonGatewayObj.ExecuteNonQuery(strupdateQueryAVgRateFromComp);
                    //   ClientScript.RegisterStartupScript(this.GetType(), "Popup", "alert('Update Successfully');", true);
                    ClientScript.RegisterStartupScript(this.GetType(), "Popup", "alert('Saved Successfully');", true);
                }
            }
            else
            {
                commonGatewayObj.Insert(httable, "fund_trans_hb");
                ClientScript.RegisterStartupScript(this.GetType(), "Popup", "alert('Saved Successfully');", true);
            }

            ClearFields();
        }
        fundNameDropDownList.Focus();
    }
示例#13
0
    protected void SaveButton_Click(object sender, EventArgs e)
    {
        UnitHolderRegistration regObj = new UnitHolderRegistration();
        // UnitTransfer transferObj = new UnitTransfer();
        UnitRepurchase unitRepObj = new UnitRepurchase();

        regObj.FundCode   = FundCodeTextBox.Text.Trim();
        regObj.BranchCode = BranchCodeTextBox.Text.Trim();
        regObj.RegNumber  = RegNoTextBox.Text.Trim();

        unitRepObj.RepurchaseNo   = Convert.ToInt32(moneyReceipDropDownList.SelectedItem.Text.ToString());
        unitRepObj.RepurchaseRate = decimal.Parse(RepRateTextBox.Text.Trim().ToString());
        unitRepObj.RepurchaseDate = RepDateTextBox.Text.Trim().ToString();
        unitRepObj.PayType        = payTypeLabel.Text.ToUpper();



        try
        {
            if (opendMFDAO.IsValidRegistration(regObj))
            {
                if (unitRepBLObj.IsRepurchaseLock(regObj))
                {
                    dvContentBottom.Visible = true;
                    ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "alert('" + msgObj.Error().ToString() + " " + " Repurchase Operation is locked " + "');", true);
                }

                else if (unitRepBLObj.IsDuplicateRepurchase(regObj, unitRepObj))
                {
                    dvContentBottom.Visible = true;
                    ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "alert('" + msgObj.Duplicate().ToString() + " " + "Repurchase Number " + "');", true);
                }
                else if (!unitRepBLObj.IsValidBEFTN(regObj, unitRepObj))
                {
                    dvContentBottom.Visible = true;
                    ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "alert('" + msgObj.Error().ToString() + " " + "Either No Router Number  or Account Number>13 digits " + "');", true);
                }
                else if (unitRepBLObj.IsIDAccount(regObj, unitRepObj))
                {
                    dvContentBottom.Visible = true;
                    ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "alert('" + msgObj.Error().ToString() + " " + "ID Account is not allow to BEFTN " + "');", true);
                }
                else
                {
                    long      totalSurrenderUnits = 0;
                    DataTable dtGrid = opendMFDAO.getTableDataGrid();
                    DataRow   drGrid;
                    foreach (DataGridItem gridRow in leftDataGrid.Items)
                    {
                        CheckBox leftCheckBox = (CheckBox)gridRow.FindControl("leftCheckBox");
                        if (leftCheckBox.Checked)
                        {
                            drGrid                = dtGrid.NewRow();
                            drGrid["SL_NO"]       = gridRow.Cells[1].Text.Trim().ToString();
                            drGrid["CERTIFICATE"] = gridRow.Cells[2].Text.Trim().ToString();
                            drGrid["QTY"]         = gridRow.Cells[3].Text.Trim().ToString();
                            totalSurrenderUnits   = totalSurrenderUnits + Convert.ToInt64(gridRow.Cells[3].Text.Trim().ToString());
                            dtGrid.Rows.Add(drGrid);
                        }
                    }
                    if (dtGrid.Rows.Count > 0)
                    {
                        if (totalSurrenderUnits == Convert.ToInt64(TotalUnitRepurchaseTextBox.Text) && totalSurrenderUnits == Convert.ToInt64(QtyTextBox.Text))
                        {
                            commonGatewayObj.ExecuteNonQuery("UPDATE MONEY_RECEIPT SET SL_REP_TR_RN_NO=" + unitRepObj.RepurchaseNo + "  WHERE ID=" + Convert.ToUInt64(moneyReceipDropDownList.SelectedValue.ToString()));
                            unitRepBLObj.saveRepurchase(dtGrid, regObj, unitRepObj, userObj);//save Repurchase Data
                            ClearText();

                            moneyReceipDropDownList.DataSource     = unitSaleBLObj.dtMoneyRecieptforDDL(" AND REG_BK = '" + regObj.FundCode.ToString().ToUpper() + "' AND REG_BR = '" + regObj.BranchCode.ToString().ToUpper() + "'AND RECEIPT_TYPE = 'REP' AND SL_REP_TR_RN_NO IS NULL  ORDER BY RECEIPT_NO DESC ");
                            moneyReceipDropDownList.DataTextField  = "RECEIPT_NO";
                            moneyReceipDropDownList.DataValueField = "ID";
                            moneyReceipDropDownList.DataBind();

                            leftDataGrid.DataSource = opendMFDAO.getTableDataGrid();// hide remaining Data
                            leftDataGrid.DataBind();
                            TotalUnitHoldingTextBox.Text = "";

                            ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "alert ('Save SuccessFully');", true);
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "alert ('Save Failed : Total Selected Units and Add Total Units is not equal');", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "alert ('Save Failed Due to No Sale Selected');", true);
                    }
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "alert ('Invalid Registration Number');", true);
            }
        }
        catch (Exception ex)
        {
            ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "alert ('" + msgObj.Error().ToString() + " " + ex.Message.Replace("'", "").ToString() + "');", true);
        }
    }
    public static bool InsertandUpdateCompany(string CompanyCode, string companyName, string dsecode, string PaidUpCapital, string atho_cap, string totalshare, string faceValue, string MarketLot, string sector, string product, string category, string avarageMarketRate, string baserate, string baseupdateDate, string lasttradingdate, string flug, string group, string floatdatefrom, string floatdateto, string csecode, string address1, string address2, string regoffice, string phnNo, string openingdate, string premium, string RIssuefrom, string RIssueto, string mergin, string IsBuySellChargeApplicable, string Additionalbuysellcharge, string AdditionalbuysellCommision, string propectusPublishDate, string IpoType, string marketType, string ISSUE_MNG)
    {
        CommonGateway commonGatewayObj = new CommonGateway();
        DataTable     dtsource         = new DataTable();
        string        strUPQuery       = "";
        string        strInsQuery      = "";

        string   strIsBuySellChargeApplicable = "";
        string   strAdditionalbuysellcharge = "";
        string   strAdditionalbuysellCommision = "";
        string   strLastTradindate, stropeningdate, strbaseupdatedDate, strfloatdatefromdate, strfloatdateTodate, strRIssuefromdate, strRIssuetodate, strProsPublishDate, strgroup;
        string   strcategory, strIpoType, strmarketType;
        DateTime?dtimeLastTradindate, dtimeopeningdate, dtimebaseUpdateddate, dtpropectuspublishingdate, dtimefloatdatefromdate, dtimefloatdateTo, dtimeRIssuefromfromdate, dtimeRIssuetodate;


        string   userId = (string)HttpContext.Current.Session["UserID"].ToString();
        DateTime dtimeCurrentDateTimeForLog = DateTime.Now;
        string   strCurrentDateTimeForLog   = dtimeCurrentDateTimeForLog.ToString("dd-MMM-yyyy HH:mm:ss tt", CultureInfo.InvariantCulture);


        if (!string.IsNullOrEmpty(lasttradingdate))
        {
            dtimeLastTradindate = Convert.ToDateTime(lasttradingdate);

            strLastTradindate = dtimeLastTradindate.Value.ToString("dd-MMM-yyyy");
        }
        else
        {
            dtimeLastTradindate = null;
            strLastTradindate   = "";
        }

        if (!string.IsNullOrEmpty(openingdate))
        {
            dtimeopeningdate = Convert.ToDateTime(openingdate);

            stropeningdate = dtimeopeningdate.Value.ToString("dd-MMM-yyyy");
        }
        else
        {
            dtimeopeningdate = null;
            stropeningdate   = "";
        }


        if (!string.IsNullOrEmpty(baseupdateDate))
        {
            dtimebaseUpdateddate = Convert.ToDateTime(baseupdateDate);

            strbaseupdatedDate = dtimebaseUpdateddate.Value.ToString("dd-MMM-yyyy");
        }
        else
        {
            dtimebaseUpdateddate = null;
            strbaseupdatedDate   = "";
        }
        if (!string.IsNullOrEmpty(propectusPublishDate))
        {
            dtpropectuspublishingdate = Convert.ToDateTime(propectusPublishDate);

            strProsPublishDate = dtpropectuspublishingdate.Value.ToString("dd-MMM-yyyy");
        }
        else
        {
            dtpropectuspublishingdate = null;
            strProsPublishDate        = "";
        }


        if (!string.IsNullOrEmpty(floatdatefrom))
        {
            dtimefloatdatefromdate = Convert.ToDateTime(floatdatefrom);

            strfloatdatefromdate = dtimefloatdatefromdate.Value.ToString("dd-MMM-yyyy");
        }
        else
        {
            dtimefloatdatefromdate = null;
            strfloatdatefromdate   = "";
        }

        if (!string.IsNullOrEmpty(floatdateto))
        {
            dtimefloatdateTo = Convert.ToDateTime(floatdateto);

            strfloatdateTodate = dtimefloatdateTo.Value.ToString("dd-MMM-yyyy");
        }
        else
        {
            dtimefloatdateTo   = null;
            strfloatdateTodate = "";
        }


        if (!string.IsNullOrEmpty(RIssuefrom))
        {
            dtimeRIssuefromfromdate = Convert.ToDateTime(RIssuefrom);

            strRIssuefromdate = dtimeRIssuefromfromdate.Value.ToString("dd-MMM-yyyy");
        }
        else
        {
            dtimeRIssuefromfromdate = null;
            strRIssuefromdate       = "";
        }

        if (!string.IsNullOrEmpty(RIssueto))
        {
            dtimeRIssuetodate = Convert.ToDateTime(RIssueto);

            strRIssuetodate = dtimeRIssuetodate.Value.ToString("dd-MMM-yyyy");
        }
        else
        {
            dtimeRIssuetodate = null;
            strRIssuetodate   = "";
        }

        if (IsBuySellChargeApplicable == "undefined")
        {
            strIsBuySellChargeApplicable = "";
        }
        else
        {
            strIsBuySellChargeApplicable = IsBuySellChargeApplicable;
        }

        if (Additionalbuysellcharge == "undefined")
        {
            strAdditionalbuysellcharge = "";
        }
        else
        {
            strAdditionalbuysellcharge = Additionalbuysellcharge;
        }

        if (AdditionalbuysellCommision == "undefined")
        {
            strAdditionalbuysellCommision = "";
        }
        else
        {
            strAdditionalbuysellCommision = Additionalbuysellcharge;
        }

        if (category == "0")
        {
            strcategory = "";
        }
        else
        {
            strcategory = category;
        }


        if (group == "0")
        {
            strgroup = "";
        }
        else
        {
            strgroup = group;
        }

        if (IpoType == "0")
        {
            strIpoType = "";
        }
        else
        {
            strIpoType = IpoType;
        }


        if (marketType == "0")
        {
            strmarketType = "";
        }
        else
        {
            strmarketType = marketType;
        }
        if (CompanyCode != "")
        {
            string Query = "select comp_nm,mlot,fc_val,avg_rt,rt_upd_dt,instr_cd,cseinstr_cd,trade_meth,sect_maj_cd,cat_tp,add1,add2,reg_off,opn_dt,tel,prod,atho_cap,paid_cap,no_shrs,sbase_rt,base_upd_dt,flot_dt_fm,flot_dt_to,margin,flag,premium,rissu_dt_fm,rissu_dt_to, UPD_DATE_TIME,  OP_NAME, ISSUE_MNG, MARKETTYPE,IPOTYPE, PROS_PUB_DT from comp where comp_cd ='" + CompanyCode + "'";

            dtsource = commonGatewayObj.Select(Query.ToString());
            if (dtsource.Rows.Count > 0)
            {
                DataTable companyinfoupdate = new DataTable();


                if (IsBuySellChargeApplicable == "N")
                {
                    string strDlQuery = "update comp set ISADD_HOWLACHARGE_DSE =null,ADD_HOWLACHARGE_AMTDSE =0,EXCEP_BUYSL_COMPCT_DSE =0 where comp_cd =" + CompanyCode.ToString() + "";

                    int delNumOfRows = commonGatewayObj.ExecuteNonQuery(strDlQuery);

                    strUPQuery = "update comp set instr_cd ='" + dsecode.ToString() + "',comp_nm ='" + companyName.ToString() + "',cseinstr_cd ='" + csecode.ToString() + "',trade_meth ='" + strgroup.ToString() + "',add1 ='" + address1.ToString() + "',add2 ='" + address2.ToString() + "',reg_off ='" + regoffice.ToString() + "',tel ='" + phnNo.ToString() + "',atho_cap = '" + atho_cap.ToString() + "',paid_cap =" + PaidUpCapital.ToString() + ",no_shrs =" + totalshare.ToString() + ",fc_val ='" + faceValue.ToString() + "',mlot ='" + MarketLot.ToString() + "',flot_dt_fm ='" + strfloatdatefromdate + "',flot_dt_to ='" + strfloatdateTodate + "',rissu_dt_fm ='" + strRIssuefromdate + "',rissu_dt_to ='" + strRIssuetodate + "',sbase_rt =" + baserate.ToString() + ",base_upd_dt ='" + strbaseupdatedDate + "',avg_rt ='" + avarageMarketRate.ToString() + "',rt_upd_dt ='" + strLastTradindate + "',margin = '" + mergin.ToString() + "',PROD='" + product + "',premium ='" + premium.ToString() + "',sect_maj_cd ='" + sector.ToString() + "',opn_dt ='" + stropeningdate + "',cat_tp ='" + strcategory.ToString() + "',PROS_PUB_DT='" + strProsPublishDate + "',IPOTYPE='" + strIpoType + "',MARKETTYPE='" + strmarketType + "',ISSUE_MNG='" + ISSUE_MNG + "',OP_NAME='" + userId + "',UPD_DATE_TIME='" + strCurrentDateTimeForLog + "' where comp_cd =" + CompanyCode.ToString() + "";
                }
                else
                {
                    strUPQuery = "update comp set instr_cd ='" + dsecode.ToString() + "',comp_nm ='" + companyName.ToString() + "',cseinstr_cd ='" + csecode.ToString() + "',trade_meth ='" + strgroup.ToString() + "',add1 ='" + address1.ToString() + "',add2 ='" + address2.ToString() + "',reg_off ='" + regoffice.ToString() + "',tel ='" + phnNo.ToString() + "',atho_cap = '" + atho_cap.ToString() + "',paid_cap =" + PaidUpCapital.ToString() + ",no_shrs =" + totalshare.ToString() + ",fc_val ='" + faceValue.ToString() + "',mlot ='" + MarketLot.ToString() + "',flot_dt_fm ='" + strfloatdatefromdate + "',flot_dt_to ='" + strfloatdateTodate + "',rissu_dt_fm ='" + strRIssuefromdate + "',rissu_dt_to ='" + strRIssuetodate + "',sbase_rt =" + baserate.ToString() + ",base_upd_dt ='" + strbaseupdatedDate + "',avg_rt ='" + avarageMarketRate.ToString() + "',rt_upd_dt ='" + strLastTradindate + "',margin = '" + mergin.ToString() + "',PROD='" + product + "',premium ='" + premium.ToString() + "',sect_maj_cd ='" + sector.ToString() + "',opn_dt ='" + stropeningdate + "',cat_tp ='" + strcategory.ToString() + "',ISADD_HOWLACHARGE_DSE ='" + strIsBuySellChargeApplicable.ToString() + "',ADD_HOWLACHARGE_AMTDSE ='" + strAdditionalbuysellcharge.ToString() + "',EXCEP_BUYSL_COMPCT_DSE ='" + strAdditionalbuysellCommision.ToString() + "',PROS_PUB_DT='" + strProsPublishDate + "',IPOTYPE='" + strIpoType + "',MARKETTYPE='" + strmarketType + "',ISSUE_MNG='" + ISSUE_MNG + "',OP_NAME='" + userId + "',UPD_DATE_TIME='" + strCurrentDateTimeForLog + "' where comp_cd =" + CompanyCode.ToString() + "";
                }



                int NumOfRows = commonGatewayObj.ExecuteNonQuery(strUPQuery);
                return(true);
            }
            else
            {
                DataTable companyinfo = new DataTable();

                if (IsBuySellChargeApplicable == "N")
                {
                    strInsQuery = "insert into comp(comp_cd,comp_nm,instr_cd,paid_cap,no_shrs,ATHO_CAP,fc_val,mlot, sbase_rt, base_upd_dt, avg_rt,rt_upd_dt,cat_tp,sect_maj_cd,trade_meth,flot_dt_fm,flot_dt_to,cseinstr_cd,flag,add1,add2,reg_off,tel,opn_dt,premium,rissu_dt_fm,rissu_dt_to,margin,PROS_PUB_DT,IPOTYPE,MARKETTYPE,ISSUE_MNG,OP_NAME,UPD_DATE_TIME)values(" + CompanyCode + ",'" + companyName.ToString() + "','" + dsecode.ToString() + "','" + Convert.ToDouble(PaidUpCapital) + "','" + totalshare + "','" + atho_cap + "','" + Convert.ToUInt32(faceValue.ToString()) + "','" + MarketLot + "','" + Convert.ToDouble(baserate) + "','" + strbaseupdatedDate + "','" + avarageMarketRate + "','" + strLastTradindate + "','" + strcategory + "','" + sector.ToString() + "','" + strgroup + "','" + strfloatdatefromdate + "','" + strfloatdatefromdate + "','" + csecode + "','" + flug + "','" + address1.ToString() + "','" + address2.ToString() + "','" + regoffice.ToString() + "','" + phnNo.ToString() + "','" + stropeningdate + "','" + premium.ToString() + "','" + strRIssuefromdate + "','" + strRIssuetodate + "','" + mergin.ToString() + "','" + strProsPublishDate + "','" + strIpoType + "','" + strmarketType + "','" + ISSUE_MNG + "','" + userId + "','" + strCurrentDateTimeForLog + "')";
                }
                else
                {
                    strInsQuery = "insert into comp(comp_cd,comp_nm,instr_cd,paid_cap,no_shrs,ATHO_CAP,fc_val,mlot, sbase_rt, base_upd_dt, avg_rt,rt_upd_dt,cat_tp,sect_maj_cd,trade_meth,flot_dt_fm,flot_dt_to,cseinstr_cd,flag,add1,add2,reg_off,tel,opn_dt,premium,rissu_dt_fm,rissu_dt_to,margin,ISADD_HOWLACHARGE_DSE,ADD_HOWLACHARGE_AMTDSE,EXCEP_BUYSL_COMPCT_DSE,PROS_PUB_DT,IPOTYPE,MARKETTYPE,ISSUE_MNG,OP_NAME,UPD_DATE_TIME)values(" + CompanyCode + ",'" + companyName.ToString() + "','" + dsecode.ToString() + "','" + Convert.ToDouble(PaidUpCapital) + "','" + totalshare + "','" + atho_cap + "','" + Convert.ToUInt32(faceValue.ToString()) + "','" + MarketLot + "','" + Convert.ToDouble(baserate) + "','" + strbaseupdatedDate + "','" + avarageMarketRate + "','" + strLastTradindate + "','" + strcategory + "','" + sector.ToString() + "','" + strgroup + "','" + strfloatdatefromdate + "','" + strfloatdateTodate + "','" + csecode + "','" + flug + "','" + address1.ToString() + "','" + address2.ToString() + "','" + regoffice.ToString() + "','" + phnNo.ToString() + "','" + stropeningdate + "','" + premium.ToString() + "','" + strRIssuefromdate + "','" + strRIssuetodate + "','" + mergin.ToString() + "','" + strIsBuySellChargeApplicable.ToString() + "','" + strAdditionalbuysellcharge.ToString() + "','" + strAdditionalbuysellCommision.ToString() + "','" + strProsPublishDate + "','" + strIpoType + "','" + strmarketType + "','" + ISSUE_MNG + "','" + userId + "','" + strCurrentDateTimeForLog + "')";
                }


                int NumOfRows = commonGatewayObj.ExecuteNonQuery(strInsQuery);
                return(true);
            }
        }


        return(false);
    }
示例#15
0
    public static bool InsertandUpdateUser(string userId, string useName, string UserDesignation, string Password, string confirmPassword, string userRole, string EMPID)
    {
        CommonGateway commonGatewayObj = new CommonGateway();
        DataTable     dtgetUser;
        string        passWord = "";

        if (userId != "")
        {
            string strUserID = "select * from user_table where user_id='" + userId + "'";
            dtgetUser = commonGatewayObj.Select(strUserID);
            if (dtgetUser != null && dtgetUser.Rows.Count > 0)
            {
                string EncryptionKey = "MAKV2SPBNI99212";
                byte[] clearBytes    = Encoding.Unicode.GetBytes(Password);
                using (Aes encryptor = Aes.Create())
                {
                    Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(EncryptionKey, new byte[] { 0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76 });
                    encryptor.Key = pdb.GetBytes(32);
                    encryptor.IV  = pdb.GetBytes(16);
                    using (MemoryStream ms = new MemoryStream())
                    {
                        using (CryptoStream cs = new CryptoStream(ms, encryptor.CreateEncryptor(), CryptoStreamMode.Write))
                        {
                            cs.Write(clearBytes, 0, clearBytes.Length);
                            cs.Close();
                        }
                        passWord = Convert.ToBase64String(ms.ToArray());
                    }
                }

                string strUPQuery = "update USER_TABLE set PASSWORD ='******',NAME ='" + useName + "',DESIGNATION='" + UserDesignation + "',ROLE_ID ='" + userRole + "',EMP_ID='" + EMPID + "' where USER_ID ='" + userId + "'";

                int NumOfRows = commonGatewayObj.ExecuteNonQuery(strUPQuery);
            }
            else
            {
                string    strInsQuery;
                DataTable dtID;

                string EncryptionKey = "MAKV2SPBNI99212";
                byte[] clearBytes    = Encoding.Unicode.GetBytes(Password);
                using (Aes encryptor = Aes.Create())
                {
                    Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(EncryptionKey, new byte[] { 0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76 });
                    encryptor.Key = pdb.GetBytes(32);
                    encryptor.IV  = pdb.GetBytes(16);
                    using (MemoryStream ms = new MemoryStream())
                    {
                        using (CryptoStream cs = new CryptoStream(ms, encryptor.CreateEncryptor(), CryptoStreamMode.Write))
                        {
                            cs.Write(clearBytes, 0, clearBytes.Length);
                            cs.Close();
                        }
                        passWord = Convert.ToBase64String(ms.ToArray());
                    }
                }
                string strQuery = "select max(ID)+1 as ID from  USER_TABLE";
                dtID = commonGatewayObj.Select(strQuery);

                strInsQuery = "insert into USER_TABLE(ID,USER_ID,PASSWORD,NAME,DESIGNATION,ROLE_ID,EMP_ID)values(" + dtID.Rows[0]["ID"].ToString() + ",'" + userId + "','" + passWord + "','" + useName + "','" + UserDesignation + "','" + userRole + "','" + EMPID + "')";

                int NumOfRows = commonGatewayObj.ExecuteNonQuery(strInsQuery);
            }
        }

        return(true);
    }
    protected void SaveButton_Click(object sender, EventArgs e)
    {
        UnitHolderRegistration regObj = new UnitHolderRegistration();

        UnitRepurchase unitRepObj = new UnitRepurchase();

        regObj.FundCode   = FundCodeTextBox.Text.Trim();
        regObj.BranchCode = BranchCodeTextBox.Text.Trim();
        regObj.RegNumber  = RegNoTextBox.Text.Trim();

        unitRepObj.RepurchaseNo   = Convert.ToInt32(moneyReceipDropDownList.SelectedItem.Text.ToString());
        unitRepObj.RepurchaseRate = decimal.Parse(RepRateTextBox.Text.Trim().ToString());
        unitRepObj.RepurchaseDate = RepDateTextBox.Text.Trim().ToString();
        if (EFTRadioButton.Checked)
        {
            unitRepObj.PayType = "EFT";
        }
        else
        {
            unitRepObj.PayType = "CHQ";
        }

        try
        {
            commonGatewayObj.BeginTransaction();
            if (opendMFDAO.IsValidRegistration(regObj))
            {
                if (unitRepBLObj.IsRepurchaseLock(regObj))
                {
                    ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "alert('" + msgObj.Error().ToString() + " " + " Repurchase Operation is locked " + "');", true);
                }

                else if (unitRepBLObj.IsDuplicateRepurchase(regObj, unitRepObj))
                {
                    ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "alert('" + msgObj.Duplicate().ToString() + " " + "Repurchase Number " + "');", true);
                }
                else if (Convert.ToInt64(TotalUnitRepurchaseTextBox.Text.ToString()) <= 0)
                {
                    ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "alert ('Save Failed: Surrender Value con not be equal or less than Zero');", true);
                }
                else if (!unitRepBLObj.IsValidBEFTN(regObj, unitRepObj))
                {
                    ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "alert('" + msgObj.Error().ToString() + " " + "Either No Router Number  or Account Number>13 digits " + "');", true);
                }
                else if (unitRepBLObj.IsIDAccount(regObj, unitRepObj))
                {
                    ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "alert('" + msgObj.Error().ToString() + " " + "ID Account is not allow to BEFTN " + "');", true);
                }
                else
                {
                    int       CheckCount         = 0;
                    long      surrenderCheckUnit = 0;
                    DataTable dtGrid             = opendMFDAO.getTableDataGridCDS();
                    DataRow   drGrid;
                    foreach (DataGridItem gridRow in leftDataGrid.Items)
                    {
                        CheckBox leftCheckBox = (CheckBox)gridRow.FindControl("leftCheckBox");
                        if (leftCheckBox.Checked)
                        {
                            TextBox SL_TR_NOTxt        = (TextBox)gridRow.FindControl("SL_TR_NoTextBox");
                            TextBox SURRENDER_UNITSTxt = (TextBox)gridRow.FindControl("Sale_UnitsTextBox");
                            TextBox EXIST_UNITSTxt     = (TextBox)gridRow.FindControl("Exist_UnitsTextBox");
                            drGrid                    = dtGrid.NewRow();
                            drGrid["SL_TR_NO"]        = SL_TR_NOTxt.Text.Trim().ToString();
                            drGrid["SURRENDER_UNITS"] = SURRENDER_UNITSTxt.Text.Trim().ToString();
                            drGrid["EXIST_UNITS"]     = EXIST_UNITSTxt.Text.Trim().ToString();
                            dtGrid.Rows.Add(drGrid);
                            surrenderCheckUnit = surrenderCheckUnit + Convert.ToInt64(SURRENDER_UNITSTxt.Text.Trim().ToString());
                            CheckCount++;
                        }
                    }

                    if (CheckCount == 0)
                    {
                        ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "alert ('Save Failed: No Surrender Units Selected');", true);
                    }
                    else if (surrenderCheckUnit != Convert.ToInt64(TotalUnitRepurchaseTextBox.Text.ToString()))
                    {
                        ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "alert ('Save Failed:  Selected Units Mis Match to Actual Surrender Units');", true);
                    }
                    else if ((CheckCount > 0) && (surrenderCheckUnit != Convert.ToInt64(TotalUnitRepurchaseTextBox.Text.ToString())))
                    {
                        commonGatewayObj.ExecuteNonQuery("UPDATE MONEY_RECEIPT SET SL_REP_TR_RN_NO=" + unitRepObj.RepurchaseNo + "  WHERE ID=" + Convert.ToUInt64(moneyReceipDropDownList.SelectedValue.ToString()));
                        unitRepBLObj.saveRepurchaseCDS(dtGrid, regObj, unitRepObj, userObj);//save Repurchase Data
                        ClearText();
                        commonGatewayObj.CommitTransaction();
                        moneyReceipDropDownList.DataSource     = unitSaleBLObj.dtMoneyRecieptforDDL(" AND REG_BK = '" + regObj.FundCode.ToString().ToUpper() + "' AND REG_BR = '" + regObj.BranchCode.ToString().ToUpper() + "'AND RECEIPT_TYPE = 'REP' AND SL_REP_TR_RN_NO IS NULL  ORDER BY RECEIPT_NO DESC ");
                        moneyReceipDropDownList.DataTextField  = "RECEIPT_NO";
                        moneyReceipDropDownList.DataValueField = "ID";
                        moneyReceipDropDownList.DataBind();

                        leftDataGrid.DataSource = opendMFDAO.getTableDataGridCDS();// hide remaining Data
                        leftDataGrid.DataBind();
                        TotalUnitHoldingTextBox.Text = "";
                        EFTRadioButton.Checked       = true;
                        CHQRadioButton.Checked       = false;

                        ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "alert ('Save SuccessFully');", true);
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "alert ('Save Failed: Ambiguous Situation');", true);
                    }
                }
            }
            else
            {
                ClearText();
                commonGatewayObj.RollbackTransaction();
                leftDataGrid.DataSource = opendMFDAO.getTableDataGridCDS();// hide remaining Data
                leftDataGrid.DataBind();
                TotalUnitHoldingTextBox.Text = "";
                ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "alert ('Invalid Registration Number');", true);
            }
        }
        catch (Exception ex)
        {
            ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "alert ('" + msgObj.Error().ToString() + " " + ex.Message.Replace("'", "").ToString() + "');", true);
        }
    }
示例#17
0
    public void SaveSaleUniAccountVoucher(string accountSchema)
    {
        try
        {
            int  countCheck   = 0;
            long tranNumber   = commonGatewayObj.GetMaxNo(accountSchema + ".GL_BASICINFO", "TRAN_ID");
            long contrlNumber = commonGatewayObj.GetMaxNo(accountSchema + ".GL_BASICINFO", "TO_NUMBER(CTRLNO)") - 1;

            string acc_op_id       = unitRepBLObj.getAcc_OP_ID(fundNameDropDownList.SelectedValue.ToString());
            long   acc_terminal_no = unitRepBLObj.getAcc_terminal_no(fundNameDropDownList.SelectedValue.ToString());

            int    faceValue           = unitRepBLObj.getUnitFaceValue(fundNameDropDownList.SelectedValue.ToString());
            string bankPaymentCode     = unitRepBLObj.getUnitBankPaymentCode(fundNameDropDownList.SelectedValue.ToString());
            string getUnitFundBankCode = unitRepBLObj.getUnitFundBankCode(fundNameDropDownList.SelectedValue.ToString());
            string shareCapitalCode    = "101010000";
            string premiumReserveCode  = "101020000";
            string premiumIncomeCode   = "302010000";


            Hashtable htInsert = new Hashtable();
            Hashtable htUpdate = new Hashtable();
            commonGatewayObj.BeginTransaction();
            DataTable dtFundYearEndInfo = commonGatewayObj.Select("SELECT * FROM FUND_INFO WHERE FUND_CD='" + fundNameDropDownList.SelectedValue.ToString() + "'");
            int       year          = Convert.ToDateTime(TranDateTextBox.Text.ToString()).Year;
            int       month         = Convert.ToDateTime(TranDateTextBox.Text.ToString()).Month;
            string    yearStartDate = dtFundYearEndInfo.Rows[0]["YEAR_START_MONTH"].ToString();
            string    yearEndDate   = dtFundYearEndInfo.Rows[0]["YEAR_END_MONTH"].ToString();
            if (yearStartDate == "01-JUL")
            {
                if (month < 6)
                {
                    yearEndDate = yearEndDate + "-" + year.ToString();
                    year--;
                    yearStartDate = yearStartDate + "-" + year.ToString();
                }
                else
                {
                    yearStartDate = yearStartDate + "-" + year.ToString();
                    year++;
                    yearEndDate = yearEndDate + "-" + year.ToString();
                }
            }
            else
            {
                yearStartDate = yearStartDate + "-" + year.ToString();
                yearEndDate   = yearEndDate + "-" + year.ToString();
            }
            if (unitRepBLObj.IsDuplicateAccVoucherNo(accountSchema, VoucherNoTexBox.Text.Trim(), "2", yearStartDate, yearEndDate))
            {
                ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "alert('Save Failed Duplicate Payment Voucher Number');", true);
            }
            else
            {
                decimal unitSaleQtyCash        = 0;
                decimal unitSaleTotalValueCash = 0;
                string  moneyReceiptID         = "";

                foreach (GridViewRow Drv in SaleListGridView.Rows)
                {
                    decimal unitFaceValue          = Convert.ToDecimal(faceValue);
                    decimal unitSaleQty            = Convert.ToDecimal(Drv.Cells[5].Text.ToString());
                    decimal unitSaleRate           = Convert.ToDecimal(Drv.Cells[6].Text.ToString());
                    decimal unitSaleTotalValue     = Convert.ToDecimal(Drv.Cells[7].Text.ToString());
                    decimal unitRateDiffernceValue = Convert.ToDecimal(Drv.Cells[10].Text.ToString());
                    decimal totalBankPayment       = Convert.ToDecimal(unitSaleRate * unitSaleQty);
                    decimal totalShareCapital      = Convert.ToDecimal(unitFaceValue * unitSaleQty);
                    decimal totalPremiumIncome     = Convert.ToDecimal(unitRateDiffernceValue * unitSaleQty);
                    decimal totalPremiumReserve    = (totalShareCapital + totalPremiumIncome) - totalBankPayment;


                    if (Drv.Cells[11].Text.ToString().ToUpper() == "CASH")
                    {
                        unitSaleQtyCash        = unitSaleQtyCash + Convert.ToDecimal(Drv.Cells[5].Text.ToString());
                        unitSaleTotalValueCash = unitSaleTotalValueCash + Convert.ToDecimal(Drv.Cells[7].Text.ToString());
                        if (moneyReceiptID == "")
                        {
                            moneyReceiptID = moneyReceiptID + Drv.Cells[0].Text.ToString();
                        }
                        else
                        {
                            moneyReceiptID = moneyReceiptID + "," + Drv.Cells[0].Text.ToString();
                        }
                    }
                    else
                    {
                        htUpdate = new Hashtable();
                        htUpdate.Add("ACC_VOUCHER_ENTRY_BY", userObj.UserID.ToString());
                        htUpdate.Add("ACC_VOUCHER_ENTRY_DATE", TranDateTextBox.Text.Trim());
                        htUpdate.Add("ACC_VOUCHER_NO", VoucherNoTexBox.Text.Trim().ToString());
                        commonGatewayObj.Update(htUpdate, "MONEY_RECEIPT ", "ID=" + Convert.ToInt64(Drv.Cells[0].Text.ToString()));

                        //Bank Payment
                        contrlNumber++;
                        htInsert = new Hashtable();
                        htInsert.Add("TRAN_ID", tranNumber + 1);
                        htInsert.Add("ACCCODE", bankPaymentCode);
                        htInsert.Add("BANKACNO", bankPaymentCode);
                        htInsert.Add("TRAN_TIME", DateTime.Now.ToShortTimeString());
                        htInsert.Add("TRAN_DATE", TranDateTextBox.Text.Trim());
                        htInsert.Add("REMARKS", unitSaleQty.ToString() + " Unit sold @tk." + unitSaleRate.ToString() + " per unit ");
                        htInsert.Add("TRAN_TYPE", "D");
                        htInsert.Add("VOUCHER_NO", VoucherNoTexBox.Text.Trim().ToString());
                        htInsert.Add("TOTAL_AMNT", totalBankPayment);
                        htInsert.Add("CTRLNO", contrlNumber);
                        htInsert.Add("OP_ID", userObj.UserID.ToString());
                        htInsert.Add("VOUCHER_TYPE", "2");
                        if (Drv.Cells[11].Text.ToString().ToUpper() == "BOTH")
                        {
                            htInsert.Add("CHEQUENO", Drv.Cells[8].Text.Trim().ToString() + " ,CASH");
                            htInsert.Add("CHEQUE_DATE", Drv.Cells[9].Text.Trim().ToString());
                        }
                        else if (Drv.Cells[11].Text.ToString().ToUpper() == "MULT")
                        {
                        }
                        else
                        {
                            htInsert.Add("CHEQUENO", Drv.Cells[8].Text.Trim().ToString());
                            htInsert.Add("CHEQUE_DATE", Drv.Cells[9].Text.Trim().ToString());
                        }
                        htInsert.Add("TERMINAL_NO", acc_terminal_no);
                        htInsert.Add("RECENT", "y");
                        htInsert.Add("LATESTDEL", "m");
                        htInsert.Add("ISOUT", "N");
                        htInsert.Add("ISREV", "N");
                        htInsert.Add("OLDDATA", "N");
                        commonGatewayObj.Insert(htInsert, accountSchema + ".GL_TRAN");
                        //ShareCapital
                        contrlNumber++;
                        htInsert = new Hashtable();
                        htInsert.Add("TRAN_ID", tranNumber + 1);
                        htInsert.Add("ACCCODE", shareCapitalCode);
                        htInsert.Add("BANKACNO_CONTRA", shareCapitalCode);
                        htInsert.Add("TRAN_TIME", DateTime.Now.ToShortTimeString());
                        htInsert.Add("TRAN_DATE", TranDateTextBox.Text.Trim());
                        htInsert.Add("REMARKS", unitSaleQty.ToString() + " Unit sold @tk." + unitSaleRate.ToString() + " per unit ");
                        htInsert.Add("TRAN_TYPE", "C");
                        htInsert.Add("VOUCHER_NO", VoucherNoTexBox.Text.Trim().ToString());
                        htInsert.Add("TOTAL_AMNT", totalShareCapital);
                        htInsert.Add("CTRLNO", contrlNumber);
                        htInsert.Add("OP_ID", userObj.UserID.ToString());
                        htInsert.Add("VOUCHER_TYPE", "2");
                        htInsert.Add("TERMINAL_NO", acc_terminal_no);
                        htInsert.Add("RECENT", "y");
                        htInsert.Add("LATESTDEL", "m");
                        htInsert.Add("ISOUT", "N");
                        htInsert.Add("ISREV", "N");
                        htInsert.Add("OLDDATA", "N");
                        commonGatewayObj.Insert(htInsert, accountSchema + ".GL_TRAN");

                        //Premimum Income
                        contrlNumber++;
                        htInsert = new Hashtable();
                        htInsert.Add("TRAN_ID", tranNumber + 1);
                        htInsert.Add("ACCCODE", premiumIncomeCode);
                        htInsert.Add("BANKACNO_CONTRA", premiumIncomeCode);
                        htInsert.Add("TRAN_TIME", DateTime.Now.ToShortTimeString());
                        htInsert.Add("TRAN_DATE", TranDateTextBox.Text.Trim());
                        htInsert.Add("REMARKS", unitSaleQty.ToString() + " Unit sold @tk." + unitSaleRate.ToString() + " per unit ");
                        htInsert.Add("TRAN_TYPE", "C");
                        htInsert.Add("VOUCHER_NO", VoucherNoTexBox.Text.Trim().ToString());
                        htInsert.Add("TOTAL_AMNT", totalPremiumIncome);
                        htInsert.Add("CTRLNO", contrlNumber);
                        htInsert.Add("OP_ID", userObj.UserID.ToString());
                        htInsert.Add("VOUCHER_TYPE", "2");
                        htInsert.Add("TERMINAL_NO", acc_terminal_no);
                        htInsert.Add("RECENT", "y");
                        htInsert.Add("LATESTDEL", "m");
                        htInsert.Add("ISOUT", "N");
                        htInsert.Add("ISREV", "N");
                        htInsert.Add("OLDDATA", "N");
                        commonGatewayObj.Insert(htInsert, accountSchema + ".GL_TRAN");

                        //premium reserve

                        if (totalPremiumReserve > 0)
                        {
                            contrlNumber++;
                            htInsert = new Hashtable();
                            htInsert.Add("TRAN_ID", tranNumber + 1);
                            htInsert.Add("ACCCODE", premiumReserveCode);
                            htInsert.Add("BANKACNO", premiumReserveCode);
                            htInsert.Add("TRAN_TIME", DateTime.Now.ToShortTimeString());
                            htInsert.Add("TRAN_DATE", TranDateTextBox.Text.Trim());
                            htInsert.Add("REMARKS", unitSaleQty.ToString() + " unit sold @tk." + unitSaleRate.ToString() + " per unit ");
                            htInsert.Add("TRAN_TYPE", "D");
                            htInsert.Add("VOUCHER_NO", VoucherNoTexBox.Text.Trim().ToString());
                            htInsert.Add("TOTAL_AMNT", totalPremiumReserve);
                            htInsert.Add("CTRLNO", contrlNumber);
                            htInsert.Add("OP_ID", userObj.UserID.ToString());
                            htInsert.Add("VOUCHER_TYPE", "2");
                            htInsert.Add("TERMINAL_NO", acc_terminal_no);
                            htInsert.Add("RECENT", "y");
                            htInsert.Add("LATESTDEL", "m");
                            htInsert.Add("ISOUT", "N");
                            htInsert.Add("ISREV", "N");
                            htInsert.Add("OLDDATA", "N");
                            commonGatewayObj.Insert(htInsert, accountSchema + ".GL_TRAN");
                        }
                        else if (totalPremiumReserve < 0)
                        {
                            contrlNumber++;
                            htInsert = new Hashtable();
                            htInsert.Add("TRAN_ID", tranNumber + 1);
                            htInsert.Add("ACCCODE", premiumReserveCode);
                            htInsert.Add("BANKACNO_CONTRA", premiumReserveCode);
                            htInsert.Add("TRAN_TIME", DateTime.Now.ToShortTimeString());
                            htInsert.Add("TRAN_DATE", TranDateTextBox.Text.Trim());
                            htInsert.Add("REMARKS", unitSaleQty.ToString() + " unit sold @tk." + unitSaleRate.ToString() + " per unit ");
                            htInsert.Add("TRAN_TYPE", "C");
                            htInsert.Add("VOUCHER_NO", VoucherNoTexBox.Text.Trim().ToString());
                            htInsert.Add("TOTAL_AMNT", totalPremiumReserve * (-1));
                            htInsert.Add("CTRLNO", contrlNumber);
                            htInsert.Add("OP_ID", userObj.UserID.ToString());
                            htInsert.Add("VOUCHER_TYPE", "2");
                            htInsert.Add("TERMINAL_NO", acc_terminal_no);
                            htInsert.Add("RECENT", "y");
                            htInsert.Add("LATESTDEL", "m");
                            htInsert.Add("ISOUT", "N");
                            htInsert.Add("ISREV", "N");
                            htInsert.Add("OLDDATA", "N");
                            commonGatewayObj.Insert(htInsert, accountSchema + ".GL_TRAN");
                        }
                    }

                    countCheck++;

                    if (countCheck == SaleListGridView.Rows.Count && unitSaleQtyCash > 0 && unitSaleTotalValueCash > 0)
                    {
                        decimal totalBankPaymentCash    = Convert.ToDecimal(unitSaleRate * unitSaleQtyCash);
                        decimal totalShareCapitalCash   = Convert.ToDecimal(unitFaceValue * unitSaleQtyCash);
                        decimal totalPremiumIncomeCash  = Convert.ToDecimal(unitRateDiffernceValue * unitSaleQtyCash);
                        decimal totalPremiumReserveCash = (totalShareCapitalCash + totalPremiumIncomeCash) - totalBankPaymentCash;
                        htUpdate = new Hashtable();
                        htUpdate.Add("ACC_VOUCHER_ENTRY_BY", userObj.UserID.ToString());
                        htUpdate.Add("ACC_VOUCHER_ENTRY_DATE", TranDateTextBox.Text.Trim());
                        htUpdate.Add("ACC_VOUCHER_NO", VoucherNoTexBox.Text.Trim().ToString());
                        commonGatewayObj.Update(htUpdate, "MONEY_RECEIPT ", "ID IN (" + moneyReceiptID + ")");

                        //Bank Payment
                        contrlNumber++;
                        htInsert = new Hashtable();
                        htInsert.Add("TRAN_ID", tranNumber + 1);
                        htInsert.Add("ACCCODE", bankPaymentCode);
                        htInsert.Add("BANKACNO", bankPaymentCode);
                        htInsert.Add("TRAN_TIME", DateTime.Now.ToShortTimeString());
                        htInsert.Add("TRAN_DATE", TranDateTextBox.Text.Trim());
                        htInsert.Add("REMARKS", unitSaleQtyCash.ToString() + " Unit sold @tk." + unitSaleRate.ToString() + " per unit ");
                        htInsert.Add("TRAN_TYPE", "D");
                        htInsert.Add("VOUCHER_NO", VoucherNoTexBox.Text.Trim().ToString());
                        htInsert.Add("TOTAL_AMNT", totalBankPaymentCash);
                        htInsert.Add("CTRLNO", contrlNumber);
                        htInsert.Add("OP_ID", userObj.UserID.ToString());
                        htInsert.Add("VOUCHER_TYPE", "2");
                        htInsert.Add("CHEQUENO", "CASH");
                        htInsert.Add("TERMINAL_NO", acc_terminal_no);
                        htInsert.Add("RECENT", "y");
                        htInsert.Add("LATESTDEL", "m");
                        htInsert.Add("ISOUT", "N");
                        htInsert.Add("ISREV", "N");
                        htInsert.Add("OLDDATA", "N");
                        commonGatewayObj.Insert(htInsert, accountSchema + ".GL_TRAN");
                        //ShareCapital
                        contrlNumber++;
                        htInsert = new Hashtable();
                        htInsert.Add("TRAN_ID", tranNumber + 1);
                        htInsert.Add("ACCCODE", shareCapitalCode);
                        htInsert.Add("BANKACNO_CONTRA", shareCapitalCode);
                        htInsert.Add("TRAN_TIME", DateTime.Now.ToShortTimeString());
                        htInsert.Add("TRAN_DATE", TranDateTextBox.Text.Trim());
                        htInsert.Add("REMARKS", unitSaleQtyCash.ToString() + " Unit sold @tk." + unitSaleRate.ToString() + " per unit ");
                        htInsert.Add("TRAN_TYPE", "C");
                        htInsert.Add("VOUCHER_NO", VoucherNoTexBox.Text.Trim().ToString());
                        htInsert.Add("TOTAL_AMNT", totalShareCapitalCash);
                        htInsert.Add("CTRLNO", contrlNumber);
                        htInsert.Add("OP_ID", userObj.UserID.ToString());
                        htInsert.Add("VOUCHER_TYPE", "2");
                        htInsert.Add("TERMINAL_NO", acc_terminal_no);
                        htInsert.Add("RECENT", "y");
                        htInsert.Add("LATESTDEL", "m");
                        htInsert.Add("ISOUT", "N");
                        htInsert.Add("ISREV", "N");
                        htInsert.Add("OLDDATA", "N");
                        commonGatewayObj.Insert(htInsert, accountSchema + ".GL_TRAN");

                        //Premimum Income
                        contrlNumber++;
                        htInsert = new Hashtable();
                        htInsert.Add("TRAN_ID", tranNumber + 1);
                        htInsert.Add("ACCCODE", premiumIncomeCode);
                        htInsert.Add("BANKACNO_CONTRA", premiumIncomeCode);
                        htInsert.Add("TRAN_TIME", DateTime.Now.ToShortTimeString());
                        htInsert.Add("TRAN_DATE", TranDateTextBox.Text.Trim());
                        htInsert.Add("REMARKS", unitSaleQtyCash.ToString() + " Unit sold @tk." + unitSaleRate.ToString() + " per unit ");
                        htInsert.Add("TRAN_TYPE", "C");
                        htInsert.Add("VOUCHER_NO", VoucherNoTexBox.Text.Trim().ToString());
                        htInsert.Add("TOTAL_AMNT", totalPremiumIncomeCash);
                        htInsert.Add("CTRLNO", contrlNumber);
                        htInsert.Add("OP_ID", userObj.UserID.ToString());
                        htInsert.Add("VOUCHER_TYPE", "2");
                        htInsert.Add("TERMINAL_NO", acc_terminal_no);
                        htInsert.Add("RECENT", "y");
                        htInsert.Add("LATESTDEL", "m");
                        htInsert.Add("ISOUT", "N");
                        htInsert.Add("ISREV", "N");
                        htInsert.Add("OLDDATA", "N");
                        commonGatewayObj.Insert(htInsert, accountSchema + ".GL_TRAN");

                        //premium reserve

                        if (totalPremiumReserve > 0)
                        {
                            contrlNumber++;
                            htInsert = new Hashtable();
                            htInsert.Add("TRAN_ID", tranNumber + 1);
                            htInsert.Add("ACCCODE", premiumReserveCode);
                            htInsert.Add("BANKACNO", premiumReserveCode);
                            htInsert.Add("TRAN_TIME", DateTime.Now.ToShortTimeString());
                            htInsert.Add("TRAN_DATE", TranDateTextBox.Text.Trim());
                            htInsert.Add("REMARKS", unitSaleQtyCash.ToString() + " unit sold @tk." + unitSaleRate.ToString() + " per unit ");
                            htInsert.Add("TRAN_TYPE", "D");
                            htInsert.Add("VOUCHER_NO", VoucherNoTexBox.Text.Trim().ToString());
                            htInsert.Add("TOTAL_AMNT", totalPremiumReserveCash);
                            htInsert.Add("CTRLNO", contrlNumber);
                            htInsert.Add("OP_ID", userObj.UserID.ToString());
                            htInsert.Add("VOUCHER_TYPE", "2");
                            htInsert.Add("TERMINAL_NO", acc_terminal_no);
                            htInsert.Add("RECENT", "y");
                            htInsert.Add("LATESTDEL", "m");
                            htInsert.Add("ISOUT", "N");
                            htInsert.Add("ISREV", "N");
                            htInsert.Add("OLDDATA", "N");
                            commonGatewayObj.Insert(htInsert, accountSchema + ".GL_TRAN");
                        }
                        else if (totalPremiumReserve < 0)
                        {
                            contrlNumber++;
                            htInsert = new Hashtable();
                            htInsert.Add("TRAN_ID", tranNumber + 1);
                            htInsert.Add("ACCCODE", premiumReserveCode);
                            htInsert.Add("BANKACNO_CONTRA", premiumReserveCode);
                            htInsert.Add("TRAN_TIME", DateTime.Now.ToShortTimeString());
                            htInsert.Add("TRAN_DATE", TranDateTextBox.Text.Trim());
                            htInsert.Add("REMARKS", unitSaleQtyCash.ToString() + " unit sold @tk." + unitSaleRate.ToString() + " per unit ");
                            htInsert.Add("TRAN_TYPE", "C");
                            htInsert.Add("VOUCHER_NO", VoucherNoTexBox.Text.Trim().ToString());
                            htInsert.Add("TOTAL_AMNT", totalPremiumReserveCash * (-1));
                            htInsert.Add("CTRLNO", contrlNumber);
                            htInsert.Add("OP_ID", userObj.UserID.ToString());
                            htInsert.Add("VOUCHER_TYPE", "2");
                            htInsert.Add("TERMINAL_NO", acc_terminal_no);
                            htInsert.Add("RECENT", "y");
                            htInsert.Add("LATESTDEL", "m");
                            htInsert.Add("ISOUT", "N");
                            htInsert.Add("ISREV", "N");
                            htInsert.Add("OLDDATA", "N");
                            commonGatewayObj.Insert(htInsert, accountSchema + ".GL_TRAN");
                        }
                    }
                }


                contrlNumber++;
                tranNumber++;
                commonGatewayObj.ExecuteNonQuery(" UPDATE " + accountSchema + ".GL_BASICINFO SET TRAN_ID=" + tranNumber + " , CTRLNO='" + contrlNumber + "' WHERE 1=1");
                commonGatewayObj.CommitTransaction();
            }
        }
        catch (Exception ex)
        {
            commonGatewayObj.RollbackTransaction();
            throw ex;
        }
    }
示例#18
0
    public void Save(DataTable dt)
    {
        string strBalanceDate, strLastBalDate, strLastUpadateDate, strLastUpadatePlusOneDate, strUpdateFundTransHB, strDelFromFundFolioHB, strMarketPriceDate, temp;

        DateTime?     dtimeBalanceDate, dtimeLastBalDate, dtimeLastUpadateDate, dtimeLastUpadatePlusOneDate, dtMarketPriceDate;
        DataTable     dtFromFundTransHB = new DataTable();
        DataTable     dtFromFundFolioHB = new DataTable();
        CommonGateway commonGatewayObj  = new CommonGateway();
        DataTable     dtSource          = new DataTable();
        DataTable     dtSource2         = new DataTable();

        DataTable tblAllfundInfo = dt;


        List <string> fundBalanceDate = (from row in tblAllfundInfo.AsEnumerable()
                                         select row["LastUpadateDate"].ToString()).ToList();
        string lastupdateddate = "01-JUL-2002";

        if (fundBalanceDate.Contains(lastupdateddate.ToString()))
        {
            ClientScript.RegisterStartupScript(this.GetType(), "Popup", "alert('Process will be started from July 2002.');", true);
        }


        for (int i = 0; i < tblAllfundInfo.Rows.Count; i++)
        {
            if (!string.IsNullOrEmpty(tblAllfundInfo.Rows[i]["BalanceDate"].ToString()))
            {
                dtimeBalanceDate = Convert.ToDateTime(tblAllfundInfo.Rows[i]["BalanceDate"].ToString());

                strBalanceDate = dtimeBalanceDate.Value.ToString("dd-MMM-yyyy");
            }
            else
            {
                dtimeBalanceDate = null;
                strBalanceDate   = "";
            }

            if (!string.IsNullOrEmpty(tblAllfundInfo.Rows[i]["LastBalDate"].ToString()))
            {
                dtimeLastBalDate = Convert.ToDateTime(tblAllfundInfo.Rows[i]["LastBalDate"].ToString());
                strLastBalDate   = dtimeLastBalDate.Value.ToString("dd-MMM-yyyy");
            }
            else
            {
                dtimeLastBalDate = null;
                strLastBalDate   = "";
            }
            if (!string.IsNullOrEmpty(tblAllfundInfo.Rows[i]["LastUpadateDate"].ToString()))
            {
                dtimeLastUpadateDate        = Convert.ToDateTime(tblAllfundInfo.Rows[i]["LastUpadateDate"].ToString());
                strLastUpadateDate          = dtimeLastUpadateDate.Value.ToString("dd-MMM-yyyy");
                dtimeLastUpadatePlusOneDate = dtimeLastUpadateDate.Value.AddDays(1);
                strLastUpadatePlusOneDate   = dtimeLastUpadatePlusOneDate.Value.ToString("dd-MMM-yyyy");
            }
            else
            {
                dtimeLastUpadateDate        = null;
                strLastUpadateDate          = "";
                dtimeLastUpadatePlusOneDate = null;
                strLastUpadatePlusOneDate   = "";
            }

            if (!string.IsNullOrEmpty(tblAllfundInfo.Rows[i]["MarketPriceDate"].ToString()))
            {
                dtMarketPriceDate  = Convert.ToDateTime(tblAllfundInfo.Rows[i]["MarketPriceDate"].ToString());
                strMarketPriceDate = dtMarketPriceDate.Value.ToString("dd-MMM-yyyy");
            }
            else
            {
                dtMarketPriceDate  = null;
                strMarketPriceDate = "";
            }

            if (dtimeBalanceDate > dtimeLastBalDate)
            {
                temp = adv_proc1(strLastUpadatePlusOneDate, strBalanceDate, tblAllfundInfo.Rows[i]["F_CD"].ToString());
            }
            else
            {
                commonGatewayObj.BeginTransaction();
                strDelFromFundFolioHB = "delete from fund_folio_hb where f_cd =" + tblAllfundInfo.Rows[i]["F_CD"].ToString();
                int noDelRowsFromFundFolioHB = commonGatewayObj.ExecuteNonQuery(strDelFromFundFolioHB);

                strUpdateFundTransHB = "update fund_trans_hb set cost_rate = null,crt_aft_com = null where f_cd =" + tblAllfundInfo.Rows[i]["F_CD"].ToString();
                int noUpdRowsFundTransHB = commonGatewayObj.ExecuteNonQuery(strUpdateFundTransHB);
                commonGatewayObj.CommitTransaction();

                temp = adv_proc1(strLastUpadatePlusOneDate, strBalanceDate, tblAllfundInfo.Rows[i]["F_CD"].ToString());
            }


            string strCompnayTransdate = "select a.comp_cd, max(a.tran_date) tran_date from market_price a, fund_folio_hb b where a.comp_cd = b.comp_cd and b.f_cd =" + tblAllfundInfo.Rows[i]["F_CD"].ToString() + " and a.tran_date <= '" + strBalanceDate + "' group by a.comp_cd order by a.comp_cd";

            dtSource = commonGatewayObj.Select(strCompnayTransdate);

            List <CompanayTransdate>  lstCompnayTransdate = new List <CompanayTransdate>();
            List <CompanyAvarageRate> lstCompnayAvgrate   = new List <CompanyAvarageRate>();
            lstCompnayTransdate = (from DataRow dr in dtSource.Rows
                                   select new CompanayTransdate()
            {
                COMP_CD = dr["COMP_CD"].ToString(),
                TRAN_DATE = dr["TRAN_DATE"].ToString()
            }).ToList();

            string dltQuery     = "delete from mprice_temp where f_cd=" + tblAllfundInfo.Rows[i]["F_CD"].ToString();
            int    dltNumOfRows = commonGatewayObj.ExecuteNonQuery(dltQuery);

            foreach (CompanayTransdate comtransdate in lstCompnayTransdate)
            {
                string strInsQuery = "select " + tblAllfundInfo.Rows[i]["F_CD"].ToString() + " as FundId, comp_cd, avg_rt from  market_price where comp_cd = " + comtransdate.COMP_CD + " and tran_date = '" + Convert.ToDateTime(comtransdate.TRAN_DATE).ToString("dd-MMM-yyyy") + "'";

                dtSource2 = commonGatewayObj.Select(strInsQuery);

                lstCompnayAvgrate = (from DataRow dr in dtSource2.Rows
                                     select new CompanyAvarageRate()
                {
                    FUNDID = dr["FUNDID"].ToString(),
                    COMP_CD = dr["COMP_CD"].ToString(),
                    AVG_RT = dr["AVG_RT"].ToString()
                }).ToList();


                foreach (CompanyAvarageRate comAvgrate in lstCompnayAvgrate)
                {
                    string strQueryInsMprice_Temp = "insert into mprice_temp(f_cd, comp_cd, avg_rt) values ('" + comAvgrate.FUNDID + "','" + comAvgrate.COMP_CD + "','" + comAvgrate.AVG_RT + "')";
                    int    NumOfRows = commonGatewayObj.ExecuteNonQuery(strQueryInsMprice_Temp);
                }
            }
            string   LoginID = Session["UserID"].ToString();
            DateTime dtimeCurrentDateTimeForLog = DateTime.Now;
            string   strCurrentDateTimeForLog   = dtimeCurrentDateTimeForLog.ToString("dd-MMM-yyyy HH:mm:ss tt", CultureInfo.InvariantCulture);

            string strupdateQueryfund_control  = "update fund_control set op_name='" + LoginID + "',upd_date_time='" + strCurrentDateTimeForLog + "',bal_dt='" + strBalanceDate + "',mprice_dt='" + strMarketPriceDate + "' where f_cd =" + tblAllfundInfo.Rows[i]["F_CD"].ToString() + "";
            int    updatefund_controlNumOfRows = commonGatewayObj.ExecuteNonQuery(strupdateQueryfund_control);


            if (temp.Trim() == "Processing Completed" || temp.Trim() == "")
            {
                lblProcessing.Text = "Processing completed!!!!";
                // ClearFields();
            }
            else
            {
                lblProcessing.Text = "No data found!!!!";
                //  ClearFields();
            }
        }
    }
    protected void SaveButton_Click(object sender, EventArgs e)
    {
        UnitHolderRegistration regObj = new UnitHolderRegistration();

        regObj.FundCode   = fundCodeTextBox.Text;
        regObj.BranchCode = branchCodeTextBox.Text;
        regObj.RegNumber  = regNoTextBox.Text;



        UnitSale saleObj = new UnitSale();

        saleObj.SaleNo = Convert.ToInt32(saleNumberTextBox.Text.Trim().ToString());
        if (moneyReceipDropDownList.SelectedValue.ToString() != "0")
        {
            saleObj.MoneyReceiptNo = Convert.ToInt32(moneyReceipDropDownList.SelectedItem.Text.ToString());
        }
        if (ChqRadioButton.Checked)
        {
            saleObj.PaymentType = ChequeTypeDropDownList.SelectedValue.ToString();
            if (CHQDDNoRemarksTextBox.Text.Trim() != "")
            {
                saleObj.ChequeNo = CHQDDNoRemarksTextBox.Text.Trim().ToString();
            }
            if (chequeDateTextBox.Text.Trim() != "")
            {
                saleObj.ChequeDate = chequeDateTextBox.Text.Trim().ToString();
            }
            if (bankNameDropDownList.SelectedValue.Trim() != "0")
            {
                saleObj.BankCode = Convert.ToInt16(bankNameDropDownList.SelectedValue.ToString());
            }
            if (branchNameDropDownList.SelectedValue.Trim() != "0" && branchNameDropDownList.SelectedValue.Trim() != "")
            {
                saleObj.BranchCode = Convert.ToInt16(branchNameDropDownList.SelectedValue.ToString());
            }
        }
        else if (CashRadioButton.Checked)
        {
            saleObj.PaymentType = "CASH";
            saleObj.CashAmount  = Convert.ToDecimal(Convert.ToDecimal(saleRateTextBox.Text.Trim().ToString()) * Convert.ToInt32(unitQtyTextBox.Text.Trim().ToString()));
        }
        else if (BothRadioButton.Checked)
        {
            saleObj.PaymentType = "BOTH";
            saleObj.ChequeNo    = CHQDDNoRemarksTextBox.Text.Trim().ToString();
            if (CHQDDNoRemarksTextBox.Text.Trim() != "")
            {
                saleObj.ChequeNo = CHQDDNoRemarksTextBox.Text.Trim().ToString();
            }
            if (chequeDateTextBox.Text.Trim() != "")
            {
                saleObj.ChequeDate = chequeDateTextBox.Text.Trim().ToString();
            }
            if (bankNameDropDownList.SelectedValue.Trim() != "0")
            {
                saleObj.BankCode = Convert.ToInt16(bankNameDropDownList.SelectedValue.ToString());
            }
            if (branchNameDropDownList.SelectedValue.Trim() != "0" || branchNameDropDownList.SelectedValue.Trim() != "")
            {
                saleObj.BranchCode = Convert.ToInt16(branchNameDropDownList.SelectedValue.ToString());
            }
            if (CashAmountTextBox.Text.Trim() != "")
            {
                saleObj.CashAmount = Convert.ToDecimal(CashAmountTextBox.Text.Trim().ToString());
            }
        }
        else if (MultiRadioButton.Checked)
        {
            saleObj.PaymentType = "MULTI";
            if (MultiplePayTypeTextBox.Text.Trim() != "")
            {
                saleObj.MultiPayType = MultiplePayTypeTextBox.Text.Trim().ToString();
            }
        }
        saleObj.SaleRate         = Convert.ToDecimal(saleRateTextBox.Text.Trim().ToString());
        saleObj.SaleType         = saleTypeDropDownList.SelectedValue.ToString().ToUpper();
        saleObj.SaleUnitQty      = Convert.ToInt32(unitQtyTextBox.Text.Trim().ToString());
        saleObj.SaleDate         = saleDateTextBox.Text.Trim().ToString();
        saleObj.SaleRemarks      = saleRemarksTextBox.Text.Trim().ToString();
        saleObj.SellingAgentCode = Convert.ToInt32(sellingAgentCodeTextBox.Text.Trim().ToString());
        int  saleLimitLower  = unitSaleBLObj.SaleLimitLower(regObj);
        long saleLimmitUpper = unitSaleBLObj.SaleLimitUpper(regObj);



        try
        {
            if (unitSaleBLObj.IsSaleLock(regObj))//Cheking Lock in status
            {
                ClientScript.RegisterStartupScript(this.GetType(), "Popup", "alert('" + msgObj.Error().ToString() + " " + " Sale Operation is Locked " + "');", true);
            }
            else if (unitSaleBLObj.IsDuplicateSale(regObj, saleObj))// Checking Duplicate Sale No
            {
                ClientScript.RegisterStartupScript(this.GetType(), "Popup", "alert('" + msgObj.Duplicate().ToString() + " " + "Sale Number " + "');", true);
            }
            else if (saleLimitLower > Convert.ToInt32(unitQtyTextBox.Text.Trim().ToString()) && saleTypeDropDownList.SelectedValue.ToString() == "SL")
            {
                unitQtyTextBox.Focus();
                ClientScript.RegisterStartupScript(this.GetType(), "Popup", "alert('Sale Unit Quantity can not less than " + saleLimitLower.ToString() + "');", true);
            }
            else if (saleLimmitUpper < Convert.ToInt32(unitQtyTextBox.Text.Trim().ToString()))
            {
                unitQtyTextBox.Focus();
                ClientScript.RegisterStartupScript(this.GetType(), "Popup", "alert('Sale Unit Quantity can not greater than " + saleLimmitUpper.ToString() + "');", true);
            }
            else
            {
                int       rowNumber = 1;
                int       line      = 0;
                DataTable dtDino    = opendMFDAO.getTableDinomination();
                DataRow   drDino;
                bool      invalidCert       = false;
                bool      allocateCert      = true;
                bool      bannedCert        = false;
                int       duplicateCerNoReg = 0;
                string    dino  = "";
                string    cerNo = "";
                foreach (DataGridItem gridItem in dinoGridView.Items)
                {
                    drDino = dtDino.NewRow();
                    TextBox txtDino   = null;
                    TextBox txtCert   = null;
                    TextBox txtWeight = null;
                    txtDino           = (TextBox)(gridItem.FindControl("dinoTextBox"));
                    txtCert           = (TextBox)(gridItem.FindControl("certNoTextBox"));
                    txtWeight         = (TextBox)(gridItem.FindControl("weightTextBox"));
                    duplicateCerNoReg = opendMFDAO.duplicateCerNoReg(regObj, txtDino.Text.ToString(), txtCert.Text.ToString());
                    allocateCert      = unitSaleBLObj.IsCertificateAllocate(regObj, txtDino.Text.ToString(), txtCert.Text.ToString());
                    bannedCert        = unitSaleBLObj.IsCertificateBanned(regObj, txtDino.Text.ToString(), txtCert.Text.ToString());
                    if (duplicateCerNoReg == 0)
                    {
                        if (saleTypeDropDownList.SelectedValue.ToString().ToUpper() == "CIP")
                        {
                            if (opendMFDAO.validationDino(txtDino.Text.ToString().ToUpper(), regObj.FundCode.ToString().ToUpper()))
                            {
                                if (allocateCert)
                                {
                                    if (bannedCert)
                                    {
                                        bannedCert = true;
                                        line       = rowNumber;
                                        dino       = txtDino.Text.Trim().ToString();
                                        cerNo      = txtCert.Text.Trim().ToString();
                                        break;
                                    }
                                    else
                                    {
                                        drDino["dino"]        = txtDino.Text.Trim().ToString().ToUpper();
                                        drDino["cert_no"]     = Convert.ToInt32(txtCert.Text.Trim().ToString());
                                        drDino["cert_weight"] = Convert.ToInt32(txtWeight.Text.Trim().ToString());
                                        dtDino.Rows.Add(drDino);
                                        rowNumber++;
                                    }
                                }
                                else
                                {
                                    allocateCert = false;
                                    line         = rowNumber;
                                    dino         = txtDino.Text.Trim().ToString();
                                    cerNo        = txtCert.Text.Trim().ToString();
                                    break;
                                }
                            }
                            else
                            {
                                invalidCert = true;
                                line        = rowNumber;
                                break;
                            }
                        }

                        else if (saleTypeDropDownList.SelectedValue.ToString().ToUpper() == "SL")
                        {
                            if (opendMFDAO.validationDino(txtDino.Text.ToString().ToUpper(), regObj.FundCode.ToString().ToUpper()) && opendMFDAO.validationWeight(Convert.ToInt32(txtWeight.Text.ToString()), regObj.FundCode.ToString().ToUpper()))
                            {
                                if (allocateCert)
                                {
                                    if (bannedCert)
                                    {
                                        bannedCert = true;
                                        line       = rowNumber;
                                        dino       = txtDino.Text.Trim().ToString();
                                        cerNo      = txtCert.Text.Trim().ToString();
                                        break;
                                    }
                                    else
                                    {
                                        drDino["dino"]        = txtDino.Text.Trim().ToString().ToUpper();
                                        drDino["cert_no"]     = Convert.ToInt32(txtCert.Text.Trim().ToString());
                                        drDino["cert_weight"] = Convert.ToInt32(txtWeight.Text.Trim().ToString());
                                        dtDino.Rows.Add(drDino);
                                        rowNumber++;
                                    }
                                }
                                else
                                {
                                    allocateCert = false;
                                    line         = rowNumber;
                                    dino         = txtDino.Text.Trim().ToString();
                                    cerNo        = txtCert.Text.Trim().ToString();
                                    break;
                                }
                            }
                            else
                            {
                                invalidCert = true;
                                line        = rowNumber;
                                break;
                            }
                        }
                    }
                    else
                    {
                        dino  = txtDino.Text.Trim().ToString();
                        cerNo = txtCert.Text.Trim().ToString();
                        break;
                    }
                }

                if (duplicateCerNoReg > 0)
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "Popup", "alert('Certificate " + dino + "-" + cerNo + " is Already Sold to Reg No:" + duplicateCerNoReg + "');", true);
                }
                else
                {
                    if (invalidCert)
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "Popup", "alert('Save Failed!!Invalid Dinomination or Weight at Line: " + line + "');", true);
                    }
                    else if (!allocateCert)
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "Popup", "alert('Save Failed!! Line: " + line + " and Certificate No: " + dino + "-" + cerNo + " is not allocated in this branch');", true);
                    }
                    else if (bannedCert)
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "Popup", "alert('Save Failed!! Line: " + line + " and Certificate No: " + dino + "-" + cerNo + " is banned for sale');", true);
                    }
                    else if (!invalidCert && allocateCert && !bannedCert)
                    {
                        commonGatewayObj.BeginTransaction();
                        commonGatewayObj.ExecuteNonQuery("UPDATE U_MASTER SET SELLING_AGENT_ID=" + saleObj.SellingAgentCode + "  WHERE  REG_BK='" + regObj.FundCode + "' AND REG_BR='" + regObj.BranchCode + "' AND REG_NO='" + regObj.RegNumber + "' AND SELLING_AGENT_ID IS NULL");
                        commonGatewayObj.ExecuteNonQuery("UPDATE MONEY_RECEIPT SET SL_REP_TR_RN_NO=" + saleObj.SaleNo + "  WHERE ID=" + Convert.ToUInt64(moneyReceipDropDownList.SelectedValue.ToString()));
                        unitSaleBLObj.SaveUnitSale(regObj, saleObj, dtDino, userObj);
                        commonGatewayObj.CommitTransaction();

                        ClearText();
                        moneyReceipDropDownList.DataSource     = unitSaleBLObj.dtMoneyRecieptInfoforDDL(regObj, "SL");
                        moneyReceipDropDownList.DataTextField  = "RECEIPT_NO";
                        moneyReceipDropDownList.DataValueField = "ID";
                        moneyReceipDropDownList.DataBind();

                        ClientScript.RegisterStartupScript(this.GetType(), "Popup", "alert('" + msgObj.Success().ToString() + "');", true);
                    }
                }
            }
        }
        catch (Exception ex)
        {
            commonGatewayObj.RollbackTransaction();
            errorMassege = msgObj.ExceptionErrorMessageString(ex.Message.ToString());
            ClientScript.RegisterStartupScript(this.GetType(), "Popup", "alert ('" + msgObj.Error().ToString() + " " + errorMassege.ToString() + "');", true);
        }
    }
示例#20
0
        public void saveRepurchaseCDS(DataTable dtSaleTrInfo, UnitHolderRegistration regObj, UnitRepurchase repObj, UnitUser unitUserObj)
        {
            try
            {
                commonGatewayObj.BeginTransaction();
                Hashtable htRepurchaseRegInfo = new Hashtable();

                StringBuilder sbQuery = new StringBuilder();
                string[]      saleNoArray;
                for (int loop = 0; loop < dtSaleTrInfo.Rows.Count; loop++)
                {
                    if (dtSaleTrInfo.Rows[loop]["SL_TR_NO"].ToString().ToUpper().IndexOf('S') >= 0)
                    {
                        sbQuery = new StringBuilder();

                        saleNoArray = dtSaleTrInfo.Rows[loop]["SL_TR_NO"].ToString().Split('S');
                        sbQuery.Append("UPDATE SALE SET QTY_OUT=NVL(QTY_OUT,0)+" + Convert.ToInt64(dtSaleTrInfo.Rows[loop]["SURRENDER_UNITS"].ToString()));
                        sbQuery.Append(" WHERE REG_BK='" + regObj.FundCode.ToString().ToUpper() + "' AND REG_BR='" + regObj.BranchCode.ToString().ToUpper() + "'");
                        sbQuery.Append(" AND REG_NO=" + Convert.ToInt32(regObj.RegNumber.ToString()) + " AND SL_NO=" + Convert.ToInt32(saleNoArray[1].ToString()));

                        commonGatewayObj.ExecuteNonQuery(sbQuery.ToString());

                        htRepurchaseRegInfo = new Hashtable();
                        htRepurchaseRegInfo.Add("REP_NO", repObj.RepurchaseNo);
                        htRepurchaseRegInfo.Add("REP_DT", repObj.RepurchaseDate);
                        htRepurchaseRegInfo.Add("SL_TR_NO", dtSaleTrInfo.Rows[loop]["SL_TR_NO"]);
                        htRepurchaseRegInfo.Add("REG_BK", regObj.FundCode.ToString().ToUpper());
                        htRepurchaseRegInfo.Add("REG_BR", regObj.BranchCode.ToString().ToUpper());
                        htRepurchaseRegInfo.Add("REG_NO", regObj.RegNumber.ToString());
                        htRepurchaseRegInfo.Add("REP_PRICE", repObj.RepurchaseRate);
                        htRepurchaseRegInfo.Add("QTY", dtSaleTrInfo.Rows[loop]["SURRENDER_UNITS"]);
                        htRepurchaseRegInfo.Add("PAY_TYPE", repObj.PayType.ToString().ToUpper());
                        htRepurchaseRegInfo.Add("USER_NM", unitUserObj.UserID.ToString());
                        htRepurchaseRegInfo.Add("ENT_DT", DateTime.Now.ToString());
                        htRepurchaseRegInfo.Add("ENT_TM", DateTime.Now.ToShortTimeString().ToString());

                        commonGatewayObj.Insert(htRepurchaseRegInfo, "REPURCHASE");
                    }
                    else if (dtSaleTrInfo.Rows[loop]["SL_TR_NO"].ToString().ToUpper().IndexOf('T') >= 0)
                    {
                        sbQuery     = new StringBuilder();
                        saleNoArray = dtSaleTrInfo.Rows[loop]["SL_TR_NO"].ToString().Split('T');
                        sbQuery.Append("UPDATE TRANSFER SET QTY_OUT=NVL(QTY_OUT,0)+" + Convert.ToInt64(dtSaleTrInfo.Rows[loop]["SURRENDER_UNITS"].ToString()));
                        sbQuery.Append(" WHERE F_CD='" + regObj.FundCode.ToString().ToUpper() + "' AND BR_CODE='" + regObj.FundCode.ToString() + "_" + regObj.BranchCode.ToString().ToUpper() + "'");
                        sbQuery.Append(" AND REG_NO_I=" + Convert.ToInt32(regObj.RegNumber.ToString()) + " AND TR_NO=" + Convert.ToInt32(saleNoArray[1].ToString()));

                        commonGatewayObj.ExecuteNonQuery(sbQuery.ToString());

                        htRepurchaseRegInfo = new Hashtable();
                        htRepurchaseRegInfo.Add("REP_NO", repObj.RepurchaseNo);
                        htRepurchaseRegInfo.Add("REP_DT", repObj.RepurchaseDate);
                        htRepurchaseRegInfo.Add("SL_TR_NO", dtSaleTrInfo.Rows[loop]["SL_TR_NO"]);
                        htRepurchaseRegInfo.Add("REG_BK", regObj.FundCode.ToString().ToUpper());
                        htRepurchaseRegInfo.Add("REG_BR", regObj.BranchCode.ToString().ToUpper());
                        htRepurchaseRegInfo.Add("REG_NO", regObj.RegNumber.ToString());
                        htRepurchaseRegInfo.Add("REP_PRICE", repObj.RepurchaseRate);
                        htRepurchaseRegInfo.Add("QTY", dtSaleTrInfo.Rows[loop]["SURRENDER_UNITS"]);
                        htRepurchaseRegInfo.Add("PAY_TYPE", repObj.PayType.ToString().ToUpper());
                        htRepurchaseRegInfo.Add("USER_NM", unitUserObj.UserID.ToString());
                        htRepurchaseRegInfo.Add("ENT_DT", DateTime.Now.ToString());
                        htRepurchaseRegInfo.Add("ENT_TM", DateTime.Now.ToShortTimeString().ToString());

                        commonGatewayObj.Insert(htRepurchaseRegInfo, "REPURCHASE");
                    }
                }



                commonGatewayObj.CommitTransaction();
            }
            catch (Exception ex)
            {
                commonGatewayObj.RollbackTransaction();
                throw ex;
            }
        }
    protected void SaveButton_Click(object sender, EventArgs e)
    {
        UnitHolderRegistration regObj = new UnitHolderRegistration();

        regObj.FundCode   = fundCodeTextBox.Text;
        regObj.BranchCode = branchCodeTextBox.Text;
        regObj.RegNumber  = regNoTextBox.Text;



        UnitSale saleObj = new UnitSale();

        saleObj.SaleNo = Convert.ToInt32(saleNumberTextBox.Text.Trim().ToString());
        if (moneyReceipDropDownList.SelectedValue.ToString() != "0")
        {
            saleObj.MoneyReceiptNo = Convert.ToInt32(moneyReceipDropDownList.SelectedItem.Text.ToString());
        }
        if (ChqRadioButton.Checked)
        {
            saleObj.PaymentType = ChequeTypeDropDownList.SelectedValue.ToString();
            if (CHQDDNoRemarksTextBox.Text.Trim() != "")
            {
                saleObj.ChequeNo = CHQDDNoRemarksTextBox.Text.Trim().ToString();
            }
            if (chequeDateTextBox.Text.Trim() != "")
            {
                saleObj.ChequeDate = chequeDateTextBox.Text.Trim().ToString();
            }
            if (bankNameDropDownList.SelectedValue.Trim() != "0")
            {
                saleObj.BankCode = Convert.ToInt16(bankNameDropDownList.SelectedValue.ToString());
            }
            if (branchNameDropDownList.SelectedValue.Trim() != "0" && branchNameDropDownList.SelectedValue.Trim() != "")
            {
                saleObj.BranchCode = Convert.ToInt16(branchNameDropDownList.SelectedValue.ToString());
            }
        }
        else if (CashRadioButton.Checked)
        {
            saleObj.PaymentType = "CASH";
            saleObj.CashAmount  = Convert.ToDecimal(Convert.ToDecimal(saleRateTextBox.Text.Trim().ToString()) * Convert.ToInt32(unitQtyTextBox.Text.Trim().ToString()));
        }
        else if (BothRadioButton.Checked)
        {
            saleObj.PaymentType = "BOTH";
            saleObj.ChequeNo    = CHQDDNoRemarksTextBox.Text.Trim().ToString();
            if (CHQDDNoRemarksTextBox.Text.Trim() != "")
            {
                saleObj.ChequeNo = CHQDDNoRemarksTextBox.Text.Trim().ToString();
            }
            if (chequeDateTextBox.Text.Trim() != "")
            {
                saleObj.ChequeDate = chequeDateTextBox.Text.Trim().ToString();
            }
            if (bankNameDropDownList.SelectedValue.Trim() != "0")
            {
                saleObj.BankCode = Convert.ToInt16(bankNameDropDownList.SelectedValue.ToString());
            }
            if (branchNameDropDownList.SelectedValue.Trim() != "0" || branchNameDropDownList.SelectedValue.Trim() != "")
            {
                saleObj.BranchCode = Convert.ToInt16(branchNameDropDownList.SelectedValue.ToString());
            }
            if (CashAmountTextBox.Text.Trim() != "")
            {
                saleObj.CashAmount = Convert.ToDecimal(CashAmountTextBox.Text.Trim().ToString());
            }
        }
        else if (MultiRadioButton.Checked)
        {
            saleObj.PaymentType = "MULTI";
            if (MultiplePayTypeTextBox.Text.Trim() != "")
            {
                saleObj.MultiPayType = MultiplePayTypeTextBox.Text.Trim().ToString();
            }
        }
        saleObj.SaleRate    = Convert.ToDecimal(saleRateTextBox.Text.Trim().ToString());
        saleObj.SaleType    = saleTypeDropDownList.SelectedValue.ToString().ToUpper();
        saleObj.SaleUnitQty = Convert.ToInt32(unitQtyTextBox.Text.Trim().ToString());
        saleObj.SaleDate    = saleDateTextBox.Text.Trim().ToString();
        saleObj.SaleRemarks = saleRemarksTextBox.Text.Trim().ToString();
        int  saleLimitLower  = unitSaleBLObj.SaleLimitLower(regObj);
        long saleLimmitUpper = unitSaleBLObj.SaleLimitUpper(regObj);



        try
        {
            if (unitSaleBLObj.IsSaleLock(regObj))//Cheking Lock in status
            {
                ClientScript.RegisterStartupScript(this.GetType(), "Popup", "alert('" + msgObj.Error().ToString() + " " + " Sale Operation is Locked " + "');", true);
            }
            else if (unitSaleBLObj.IsDuplicateSale(regObj, saleObj))// Checking Duplicate Sale No
            {
                ClientScript.RegisterStartupScript(this.GetType(), "Popup", "alert('" + msgObj.Duplicate().ToString() + " " + "Sale Number " + "');", true);
            }
            else if (saleLimitLower > Convert.ToInt32(unitQtyTextBox.Text.Trim().ToString()) && saleTypeDropDownList.SelectedValue.ToString() == "SL")
            {
                unitQtyTextBox.Focus();
                ClientScript.RegisterStartupScript(this.GetType(), "Popup", "alert('Sale Unit Quantity can not less than " + saleLimitLower.ToString() + "');", true);
            }
            else if (saleLimmitUpper < Convert.ToInt32(unitQtyTextBox.Text.Trim().ToString()))
            {
                unitQtyTextBox.Focus();
                ClientScript.RegisterStartupScript(this.GetType(), "Popup", "alert('Sale Unit Quantity can not greater than " + saleLimmitUpper.ToString() + "');", true);
            }
            else
            {
                commonGatewayObj.BeginTransaction();
                commonGatewayObj.ExecuteNonQuery("UPDATE U_MASTER SET SELLING_AGENT_ID=" + saleObj.SellingAgentCode + "  WHERE  REG_BK='" + regObj.FundCode + "' AND REG_BR='" + regObj.BranchCode + "' AND REG_NO='" + regObj.RegNumber + "' AND SELLING_AGENT_ID IS NULL");
                commonGatewayObj.ExecuteNonQuery("UPDATE MONEY_RECEIPT SET SL_REP_TR_RN_NO=" + saleObj.SaleNo + "  WHERE ID=" + Convert.ToUInt64(moneyReceipDropDownList.SelectedValue.ToString()));
                unitSaleBLObj.SaveUnitSaleCDS(regObj, saleObj, userObj);
                commonGatewayObj.CommitTransaction();
                ClearText();
                moneyReceipDropDownList.DataSource     = unitSaleBLObj.dtMoneyRecieptInfoforDDL(regObj, "SL");
                moneyReceipDropDownList.DataTextField  = "RECEIPT_NO";
                moneyReceipDropDownList.DataValueField = "ID";
                moneyReceipDropDownList.DataBind();
                ClientScript.RegisterStartupScript(this.GetType(), "Popup", "alert('" + msgObj.Success().ToString() + "');", true);
            }
        }
        catch (Exception ex)
        {
            commonGatewayObj.RollbackTransaction();
            errorMassege = msgObj.ExceptionErrorMessageString(ex.Message.ToString());
            ClientScript.RegisterStartupScript(this.GetType(), "Popup", "alert ('" + msgObj.Error().ToString() + " " + errorMassege.ToString() + "');", true);
        }
    }
示例#22
0
        public void saveTransferCDS(DataTable dtSaleTrInfo, UnitHolderRegistration regObj, UnitTransfer transferObj, UnitUser unitUserObj)
        {
            try
            {
                commonGatewayObj.BeginTransaction();
                Hashtable htTransferRegInfo = new Hashtable();

                StringBuilder sbQuery = new StringBuilder();
                string[]      saleNoArray;
                for (int loop = 0; loop < dtSaleTrInfo.Rows.Count; loop++)
                {
                    if (dtSaleTrInfo.Rows[loop]["SL_TR_NO"].ToString().ToUpper().IndexOf('S') >= 0)
                    {
                        saleNoArray = dtSaleTrInfo.Rows[loop]["SL_TR_NO"].ToString().Split('S');
                        sbQuery.Append("UPDATE SALE SET QTY_OUT=NVL(QTY_OUT,0)+" + Convert.ToInt64(dtSaleTrInfo.Rows[loop]["SURRENDER_UNITS"].ToString()));
                        sbQuery.Append(" WHERE REG_BK='" + regObj.FundCode.ToString().ToUpper() + "' AND REG_BR='" + regObj.BranchCode.ToString().ToUpper() + "'");
                        sbQuery.Append(" AND REG_NO=" + Convert.ToInt32(regObj.RegNumber.ToString()) + " AND SL_NO=" + Convert.ToInt32(saleNoArray[1].ToString()));

                        commonGatewayObj.ExecuteNonQuery(sbQuery.ToString());

                        htTransferRegInfo = new Hashtable();
                        htTransferRegInfo.Add("F_CD", regObj.FundCode.ToString().ToUpper());
                        htTransferRegInfo.Add("BR_CODE", regObj.FundCode.ToString().ToUpper() + "_" + transferObj.TfereeBranchCode.ToString().ToUpper());
                        htTransferRegInfo.Add("TR_NO", Convert.ToInt32(transferObj.TransferNo.ToString()));
                        htTransferRegInfo.Add("TR_DT", Convert.ToDateTime(transferObj.TransferDate.ToString()).ToString("dd-MMM-yyyy"));
                        htTransferRegInfo.Add("REG_BK_O", regObj.FundCode.ToString().ToUpper());
                        htTransferRegInfo.Add("REG_BR_O", transferObj.TferorBranchCode.ToString().ToUpper());
                        htTransferRegInfo.Add("REG_NO_O", Convert.ToInt32(transferObj.TransferorRegNo.ToString()));
                        htTransferRegInfo.Add("QTY", Convert.ToInt32(dtSaleTrInfo.Rows[loop]["SURRENDER_UNITS"].ToString()));
                        htTransferRegInfo.Add("REG_BK_I", regObj.FundCode.ToString().ToUpper());
                        htTransferRegInfo.Add("REG_BR_I", transferObj.TfereeBranchCode.ToString().ToUpper());
                        htTransferRegInfo.Add("REG_NO_I", Convert.ToInt32(transferObj.TransfereeRegNo.ToString()));
                        htTransferRegInfo.Add("USER_NM", unitUserObj.UserID.ToString());
                        htTransferRegInfo.Add("ENT_DT", DateTime.Now.ToString());
                        htTransferRegInfo.Add("ENT_TM", DateTime.Now.ToShortTimeString().ToString());
                        htTransferRegInfo.Add("OLD_SL_TR_NO", dtSaleTrInfo.Rows[loop]["SL_TR_NO"].ToString());
                        commonGatewayObj.Insert(htTransferRegInfo, "TRANSFER");
                    }
                    else if (dtSaleTrInfo.Rows[loop]["SL_TR_NO"].ToString().ToUpper().IndexOf('T') >= 0)
                    {
                        saleNoArray = dtSaleTrInfo.Rows[loop]["SL_TR_NO"].ToString().Split('T');
                        sbQuery.Append("UPDATE TRANSFER SET QTY_OUT=NVL(QTY_OUT,0)+" + Convert.ToInt64(dtSaleTrInfo.Rows[loop]["SURRENDER_UNITS"].ToString()));
                        sbQuery.Append(" WHERE F_CD='" + regObj.FundCode.ToString().ToUpper() + "' AND BR_CODE='" + regObj.FundCode.ToString() + "_" + regObj.BranchCode.ToString().ToUpper() + "'");
                        sbQuery.Append(" AND REG_NO_I=" + Convert.ToInt32(regObj.RegNumber.ToString()) + "AND TR_NO=" + Convert.ToInt32(saleNoArray[1].ToString()));

                        commonGatewayObj.ExecuteNonQuery(sbQuery.ToString());


                        htTransferRegInfo = new Hashtable();
                        htTransferRegInfo.Add("F_CD", regObj.FundCode.ToString().ToUpper());
                        htTransferRegInfo.Add("BR_CODE", regObj.FundCode.ToString().ToUpper() + "_" + transferObj.TfereeBranchCode.ToString().ToUpper());
                        htTransferRegInfo.Add("TR_NO", Convert.ToInt32(transferObj.TransferNo.ToString()));
                        htTransferRegInfo.Add("TR_DT", Convert.ToDateTime(transferObj.TransferDate.ToString()).ToString("dd-MMM-yyyy"));
                        htTransferRegInfo.Add("REG_BK_O", regObj.FundCode.ToString().ToUpper());
                        htTransferRegInfo.Add("REG_BR_O", transferObj.TferorBranchCode.ToString().ToUpper());
                        htTransferRegInfo.Add("REG_NO_O", Convert.ToInt32(transferObj.TransferorRegNo.ToString()));
                        htTransferRegInfo.Add("QTY", Convert.ToInt32(dtSaleTrInfo.Rows[loop]["SURRENDER_UNITS"].ToString()));
                        htTransferRegInfo.Add("REG_BK_I", regObj.FundCode.ToString().ToUpper());
                        htTransferRegInfo.Add("REG_BR_I", transferObj.TfereeBranchCode.ToString().ToUpper());
                        htTransferRegInfo.Add("REG_NO_I", Convert.ToInt32(transferObj.TransfereeRegNo.ToString()));
                        htTransferRegInfo.Add("USER_NM", unitUserObj.UserID.ToString());
                        htTransferRegInfo.Add("ENT_DT", DateTime.Now.ToString());
                        htTransferRegInfo.Add("ENT_TM", DateTime.Now.ToShortTimeString().ToString());
                        htTransferRegInfo.Add("OLD_SL_TR_NO", dtSaleTrInfo.Rows[loop]["SL_TR_NO"].ToString());
                        commonGatewayObj.Insert(htTransferRegInfo, "TRANSFER");
                    }
                }



                commonGatewayObj.CommitTransaction();
            }
            catch (Exception ex)
            {
                commonGatewayObj.RollbackTransaction();
                throw ex;
            }
        }
示例#23
0
    protected void btnProcessingforBackup_Click(object sender, EventArgs e)
    {
        string confirmValue = HiddenField1.Value;

        if (confirmValue == "Yes")
        {
            DataTable dtBalanceDate = getbalanceDate();                                                         // Here date will be  max(bal_dt_ctrl)+1   from pfolio_bk
                                                                                                                // string Bal_Date1 = Convert.ToDateTime(dtBalanceDate.Rows[0]["balancedate1"]).ToString("dd-MMM-yyyy"); // Here date will be  max(bal_dt_ctrl)+1   from pfolio_bk
            DataTable dtmaximumDatefrompflio = Getmaximumdatefromportfolio_bK();                                // Here date will be  max(bal_dt_ctrl)   from pfolio_bk
            DataTable dtRateUpdatedDate      = Get_maximum_RateUpadatedate_fromComp();                          // Here date will be  max(rt_upd_dt)   from comp

            string Date1 = Convert.ToDateTime(dtmaximumDatefrompflio.Rows[0]["date1"]).ToString("dd-MMM-yyyy"); // Here date will be  max(bal_dt_ctrl)   from pfolio_bk
            string Date2 = Convert.ToDateTime(dtRateUpdatedDate.Rows[0]["date2"]).ToString("dd-MMM-yyyy");      // Here date will be  max(rt_upd_dt)   from comp
                                                                                                                // marketPriceDateTextBox.Text.ToString()

            if (Date1 == Date2)
            {
                //  ClientScript.RegisterStartupScript(this.GetType(), "Popup", "alert('Data Already Updated! or Market Price is not current');", true);
                lblProcessing.Text = "Data Already Updated! or Market Price is not current !!!";
            }
            else
            {
                //  DateTime dtbalanceDate1 = DateTime.ParseExact(txtbalanceDate1.Text, "dd/MM/yyyy", null);

                string strdtBalanceDate1 = txtbalanceDate1.Text.ToString();

                DataTable     dtsource = new DataTable();
                StringBuilder sbMst    = new StringBuilder();
                StringBuilder sbfilter = new StringBuilder();
                sbfilter.Append(" ");
                sbMst.Append("select a.F_CD, a.COMP_CD, a.TOT_NOS,nvl( a.TOT_COST,0) as TOT_COST, a.TCST_AFT_COM, a.BAL_DT, comp.avg_RT, nvl(comp.CSE_RT,0) as CSE_RT ,");
                sbMst.Append("comp.ADC_RT, sect_maj.SECT_MAJ_NM, sect_maj.SECT_MAJ_CD, '" + strdtBalanceDate1 + "' as BalanceDate from comp, mprice_temp, fund_folio_hb a, sect_maj");
                sbMst.Append(" where mprice_temp.f_cd = a.f_cd and comp.comp_cd = a.comp_cd and ");
                sbMst.Append("comp.sect_maj_cd = sect_maj.sect_maj_cd and comp.comp_cd = mprice_temp.comp_cd and a.tot_nos > 0");
                sbMst.Append(sbfilter.ToString());
                dtsource = commonGatewayObj.Select(sbMst.ToString());

                List <PortFolioBk> portFoliobkdatalist = new List <PortFolioBk>();
                portFoliobkdatalist = (from DataRow dr in dtsource.Rows
                                       select new PortFolioBk()
                {
                    F_CD = dr["F_CD"].ToString(),
                    COMP_CD = dr["COMP_CD"].ToString(),
                    TOT_NOS = dr["TOT_NOS"].ToString(),
                    TOT_COST = dr["TOT_COST"].ToString(),
                    TCST_AFT_COM = dr["TCST_AFT_COM"].ToString(),
                    BAL_DT = Convert.ToDateTime(dr["BAL_DT"]).ToString("dd-MMM-yyyy"),                        //This date from fund_folio_hb
                                                                                                              // BAL_DT = dr["BAL_DT"].ToString(),
                    avg_RT = dr["avg_RT"].ToString(),
                    CSE_RT = dr["CSE_RT"].ToString(),
                    ADC_RT = dr["ADC_RT"].ToString(),
                    SECT_MAJ_NM = dr["SECT_MAJ_NM"].ToString(),
                    SECT_MAJ_CD = dr["SECT_MAJ_CD"].ToString(),
                    BalanceDate = dr["BalanceDate"].ToString()                        // Here date will be  given input date
                }).ToList();


                foreach (PortFolioBk pk in portFoliobkdatalist)
                {
                    string strInsQuery = "insert into  pfolio_bk(F_CD,COMP_CD,TOT_NOS,TOT_COST,TCST_AFT_COM,BAL_DT,DSE_RT,CSE_RT,ADC_RT,SECT_MAJ_NM,SECT_MAJ_CD,BAL_DT_CTRL)values(" + Convert.ToInt32(pk.F_CD) + "," + Convert.ToInt32(pk.COMP_CD) + "," + Convert.ToDouble(pk.TOT_NOS) + "," + Convert.ToDouble(pk.TOT_COST) + "," + Convert.ToDouble(pk.TCST_AFT_COM) + ",TO_Date('" + pk.BAL_DT + "')," + Convert.ToDouble(pk.avg_RT) + "," + Convert.ToDouble(pk.CSE_RT) + "," + Convert.ToDouble(pk.ADC_RT) + ",'" + pk.SECT_MAJ_NM.ToString() + "','" + pk.SECT_MAJ_CD + "',TO_DATE('" + pk.BalanceDate + "'))";
                    int    NumOfRows   = commonGatewayObj.ExecuteNonQuery(strInsQuery);
                }

                ClientScript.RegisterStartupScript(this.GetType(), "Popup", "alert('Data Inserted Successfully');", true);
                DataTable dttotalrow = GetTotalrowPortfolio_bk(Convert.ToDateTime(txtbalanceDate1.Text).ToString("dd-MMM-yyyy"));
                txttotalRowCount.Text = dttotalrow.Rows[0]["TOTALROW"].ToString();
                lblProcessing.Text    = "Processing completed!!!!";
            }
        }
        else
        {
            this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('You clicked NO!')", true);
        }



        //   Response.Redirect("FinalProcessing.aspx");
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string strBalanceDate, strLastBalDate, strLastUpadateDate, strLastUpadatePlusOneDate, strUpdateFundTransHB, strDelFromFundFolioHB, strMarketPriceDate, temp;

        DateTime?     dtimeBalanceDate, dtimeLastBalDate, dtimeLastUpadateDate, dtimeLastUpadatePlusOneDate, dtMarketPriceDate;
        DataTable     dtFromFundTransHB = new DataTable();
        DataTable     dtFromFundFolioHB = new DataTable();
        CommonGateway commonGatewayObj  = new CommonGateway();
        DataTable     dtSource          = new DataTable();
        DataTable     dtSource2         = new DataTable();

        try
        {
            if (!string.IsNullOrEmpty(txtBalanceDate.Text.Trim()))
            {
                dtimeBalanceDate = Convert.ToDateTime(txtBalanceDate.Text.ToString());

                strBalanceDate = dtimeBalanceDate.Value.ToString("dd-MMM-yyyy");
            }
            else
            {
                dtimeBalanceDate = null;
                strBalanceDate   = "";
            }

            if (!string.IsNullOrEmpty(txtLastBalDate.Text.Trim()))
            {
                dtimeLastBalDate = Convert.ToDateTime(txtLastBalDate.Text.ToString());
                strLastBalDate   = dtimeLastBalDate.Value.ToString("dd-MMM-yyyy");
            }
            else
            {
                dtimeLastBalDate = null;
                strLastBalDate   = "";
            }
            if (!string.IsNullOrEmpty(txtLastUpadateDate.Text.Trim()))
            {
                dtimeLastUpadateDate        = Convert.ToDateTime(txtLastUpadateDate.Text.ToString());
                strLastUpadateDate          = dtimeLastUpadateDate.Value.ToString("dd-MMM-yyyy");
                dtimeLastUpadatePlusOneDate = dtimeLastUpadateDate.Value.AddDays(1);
                strLastUpadatePlusOneDate   = dtimeLastUpadatePlusOneDate.Value.ToString("dd-MMM-yyyy");
            }
            else
            {
                dtimeLastUpadateDate        = null;
                strLastUpadateDate          = "";
                dtimeLastUpadatePlusOneDate = null;
                strLastUpadatePlusOneDate   = "";
            }

            if (!string.IsNullOrEmpty(txtMarketPriceDate.Text.Trim()))
            {
                dtMarketPriceDate  = Convert.ToDateTime(txtMarketPriceDate.Text.ToString());
                strMarketPriceDate = dtMarketPriceDate.Value.ToString("dd-MMM-yyyy");
            }
            else
            {
                dtMarketPriceDate  = null;
                strMarketPriceDate = "";
            }
            if (dtimeBalanceDate > dtimeLastBalDate)
            {
                temp = adv_proc1(strLastUpadatePlusOneDate, strBalanceDate, fundNameDropDownList.SelectedValue.ToString());
                if (temp.Trim() == "Processing Completed")
                {
                    lblProcessing.Text = "Processing completed!!!!";
                    // ClearFields();
                }
                else
                {
                    lblProcessing.Text = "No data found!!!!";
                    //  ClearFields();
                }
                //lblProcessing.Text = "Processing completed!!!!";
                //ClearFields();
            }

            else
            {
                commonGatewayObj.BeginTransaction();
                strDelFromFundFolioHB = "delete from fund_folio_hb where f_cd =" + fundNameDropDownList.SelectedValue.ToString();
                int noDelRowsFromFundFolioHB = commonGatewayObj.ExecuteNonQuery(strDelFromFundFolioHB);

                strUpdateFundTransHB = "update fund_trans_hb set cost_rate = null,crt_aft_com = null where f_cd =" + fundNameDropDownList.SelectedValue.ToString();
                int noUpdRowsFundTransHB = commonGatewayObj.ExecuteNonQuery(strUpdateFundTransHB);
                commonGatewayObj.CommitTransaction();

                temp = adv_proc1(strLastUpadatePlusOneDate, strBalanceDate, fundNameDropDownList.SelectedValue.ToString());
                if (temp.Trim() == "Processing Completed")
                {
                    lblProcessing.Text = "Processing completed!!!!";
                    // ClearFields();
                }
                else
                {
                    lblProcessing.Text = "No data found!!!!";
                    //   ClearFields();
                }
                //  lblProcessing.Text = "Processing completed!!!!";


                // Code goes here Code goes here
            }



            string strCompnayTransdate = "select a.comp_cd, max(a.tran_date) tran_date from market_price a, fund_folio_hb b where a.comp_cd = b.comp_cd and b.f_cd =" + fundNameDropDownList.SelectedValue.ToString() + " and a.tran_date <= '" + strBalanceDate + "' group by a.comp_cd order by a.comp_cd";

            dtSource = commonGatewayObj.Select(strCompnayTransdate);

            List <CompanayTransdate>  lstCompnayTransdate = new List <CompanayTransdate>();
            List <CompanyAvarageRate> lstCompnayAvgrate   = new List <CompanyAvarageRate>();
            lstCompnayTransdate = (from DataRow dr in dtSource.Rows
                                   select new CompanayTransdate()
            {
                COMP_CD = dr["COMP_CD"].ToString(),
                TRAN_DATE = dr["TRAN_DATE"].ToString()
            }).ToList();

            string dltQuery     = "delete from mprice_temp where f_cd=" + fundNameDropDownList.SelectedValue.ToString();
            int    dltNumOfRows = commonGatewayObj.ExecuteNonQuery(dltQuery);

            foreach (CompanayTransdate comtransdate in lstCompnayTransdate)
            {
                string strInsQuery = "select " + fundNameDropDownList.SelectedValue.ToString() + " as FundId, comp_cd, avg_rt from  market_price where comp_cd = " + comtransdate.COMP_CD + " and tran_date = '" + Convert.ToDateTime(comtransdate.TRAN_DATE).ToString("dd-MMM-yyyy") + "'";

                dtSource2 = commonGatewayObj.Select(strInsQuery);

                lstCompnayAvgrate = (from DataRow dr in dtSource2.Rows
                                     select new CompanyAvarageRate()
                {
                    FUNDID = dr["FUNDID"].ToString(),
                    COMP_CD = dr["COMP_CD"].ToString(),
                    AVG_RT = dr["AVG_RT"].ToString()
                }).ToList();


                foreach (CompanyAvarageRate comAvgrate in lstCompnayAvgrate)
                {
                    string strQueryInsMprice_Temp = "insert into mprice_temp(f_cd, comp_cd, avg_rt) values ('" + comAvgrate.FUNDID + "','" + comAvgrate.COMP_CD + "','" + comAvgrate.AVG_RT + "')";
                    int    NumOfRows = commonGatewayObj.ExecuteNonQuery(strQueryInsMprice_Temp);
                }
            }
            string   LoginID = Session["UserID"].ToString();
            DateTime dtimeCurrentDateTimeForLog = DateTime.Now;
            string   strCurrentDateTimeForLog   = dtimeCurrentDateTimeForLog.ToString("dd-MMM-yyyy HH:mm:ss tt", CultureInfo.InvariantCulture);

            //string strupdateQueryfund_control = "update fund_control set bal_dt='" + strBalanceDate + "',mprice_dt='" + strMarketPriceDate + "' where f_cd =" + fundNameDropDownList.SelectedValue.ToString() + "";

            string strupdateQueryfund_control = "update fund_control set op_name='" + LoginID + "',upd_date_time='" + strCurrentDateTimeForLog + "',bal_dt='" + strBalanceDate + "',mprice_dt='" + strMarketPriceDate + "' where f_cd =" + fundNameDropDownList.SelectedValue.ToString() + "";



            int updatefund_controlNumOfRows = commonGatewayObj.ExecuteNonQuery(strupdateQueryfund_control);


            // System.Threading.Thread.Sleep(3000);

            // ClearFields();
        }
        catch (Exception ex)
        {
            ClientScript.RegisterStartupScript(this.GetType(), "Popup", "alert('" + ex.Message.ToString() + "');", true);
        }
    }