Beispiel #1
0
        public BranchInfoDTO populate(SqlDataReader reader)
        {
            try
            {
                BranchInfoDTO dto = new BranchInfoDTO();

                dto.PrimaryKey         = (Guid)reader["BR_PK"];
                dto.BT_PK              = (Guid)reader["BT_PK"];
                dto.BranchCode         = (string)reader["BranchCode"];
                dto.BranchName         = (string)reader["BranchName"];
                dto.ContactPerson      = (string)reader["ContactPerson"];
                dto.ContactPersonPhone = (string)reader["ContactPersonPhone"];
                dto.BranchPrefix       = (string)reader["BranchPrefix"];
                dto.BranchAddress      = (string)reader["BranchAddress"];
                dto.Telephone1         = (string)reader["Telephone1"];
                dto.Telephone2         = (string)reader["Telephone2"];
                dto.Telephone3         = (string)reader["Telephone3"];
                dto.Fax             = (string)reader["Fax"];
                dto.EMail           = (string)reader["EMail"];
                dto.CashInSafeLimit = (Decimal)reader["CashInSafeLimit"];

                ////dto = (string)reader[""];

                dto.EntryBy   = (string)reader["EntryBy"];
                dto.EntryDate = (DateTime)reader["EntryDate"];

                return(dto);
            }
            catch (Exception Exp)
            {
                throw Exp;
            }
        }
Beispiel #2
0
        private string Get_BranchInfoCode(BranchInfoDTO Obj)
        {
            string brcode   = null;
            int    brcodeno = 0;

            SqlConnection objmycon = new SqlConnection(ConfigurationManager.ConnectionStrings["DPOSConnectionString"].ToString());

            try
            {
                SqlCommand objcmd = new SqlCommand();

                objcmd.CommandText = "Select Isnull(Max(cast(BranchCode as int)),0 )+1 from BranchInfo";
                objmycon.Open();
                objcmd.Connection = objmycon;
                brcodeno          = (int)objcmd.ExecuteScalar();
            }
            catch (Exception Exp)
            {
                throw Exp;
            }
            finally
            {
                objmycon.Close();
            }

            brcode = brcodeno.ToString("000");
            return(brcode);
        }
    private BranchInfoDTO Populate()
    {
        string        strBT_PK;
        BranchInfoDTO dto = new BranchInfoDTO();

        if (this.txtBR_PK.Value.ToString() != "")
        {
            dto.PrimaryKey = (Guid)TypeDescriptor.GetConverter(dto.PrimaryKey).ConvertFromString(this.txtBR_PK.Value);
        }

        Guid nullGuid = Guid.NewGuid();

        nullGuid = (Guid)TypeDescriptor.GetConverter(nullGuid).ConvertFromString("00000000-0000-0000-0000-000000000000");

        strBT_PK               = (string)this.ddlBranchType.SelectedValue;
        dto.BT_PK              = strBT_PK == string.Empty ? nullGuid : (Guid)TypeDescriptor.GetConverter(dto.BT_PK).ConvertFromString(strBT_PK);
        dto.BranchCode         = this.txtBranchCode.Text;
        dto.BranchName         = this.txtBranchName.Text;
        dto.ContactPerson      = this.txtContactPerson.Text;
        dto.ContactPersonPhone = this.txtContactPersonPhone.Text;
        dto.BranchPrefix       = this.txtBranchPrefix.Text;
        dto.BranchAddress      = this.txtBranchAddress.Text;
        dto.Telephone1         = this.txtTelephone1.Text;
        dto.Telephone2         = this.txtTelephone2.Text;
        dto.Telephone3         = this.txtTelephone3.Text;
        dto.Fax   = this.txtFax.Text;
        dto.EMail = this.txtEMail.Text;

        dto.CashInSafeLimit = (Decimal)TypeDescriptor.GetConverter(dto.CashInSafeLimit).ConvertFromString(this.txtCashInSafeLimit.Text);
        dto.EntryBy         = Constants.DEFULT_USER;
        dto.EntryDate       = DateTime.Today;
        return(dto);
    }
Beispiel #4
0
        public override void Delete(object obj)
        {
            BranchInfoDTO oProductUnitInfoDto = (BranchInfoDTO)obj;

            SqlConnection objmycon = new SqlConnection(ConfigurationManager.ConnectionStrings["DPOSConnectionString"].ToString());
            SqlCommand    objcmd   = new SqlCommand();

            objcmd.CommandText = "Delete From BranchInfo WHERE BR_PK=@BR_PK";

            objcmd.Parameters.Add(new SqlParameter("@BR_PK", SqlDbType.UniqueIdentifier, 16));
            objcmd.Parameters["@BR_PK"].Value = (Guid)oProductUnitInfoDto.PrimaryKey;

            objcmd.Connection = objmycon;

            try
            {
                objmycon.Open();
                objcmd.ExecuteNonQuery();
            }
            catch (Exception Exp)
            {
                throw Exp;
            }
            finally
            {
                objmycon.Close();
                //objCmdDelete.Dispose();
                //objCmdDelete.Cancel();
            }
        }
Beispiel #5
0
        public BoothInfoDTO populate_all(SqlDataReader reader)
        {
            try
            {
                BoothInfoDTO      dto                = new BoothInfoDTO();
                BranchInfoDTO     oBranchInfoDTO     = new BranchInfoDTO();
                BranchTypeInfoDTO oBranchTypeInfoDTO = new BranchTypeInfoDTO();

                oBranchTypeInfoDTO.BT_Name     = (string)reader["BType_Name"];
                oBranchInfoDTO.BranchCode      = (string)reader["BranchCode"];
                oBranchInfoDTO.BranchName      = (string)reader["BranchName"];
                oBranchInfoDTO.ContactPerson   = (string)reader["ContactPerson"];
                oBranchInfoDTO.BranchAddress   = (string)reader["BranchAddress"];
                oBranchInfoDTO.Telephone1      = (string)reader["Telephone1"];
                oBranchInfoDTO.Telephone2      = (string)reader["Telephone2"];
                oBranchInfoDTO.Fax             = (string)reader["Fax"];
                oBranchInfoDTO.EMail           = (string)reader["EMail"];
                oBranchInfoDTO.CashInSafeLimit = (decimal)reader["CashInSafeLimit"];
                dto.BoothNo        = (Int16)reader["BoothNo"];
                dto.BoothCashLimit = (decimal)reader["BoothCashLimit"];
                dto.BoothStatus    = (bool)reader["BoothStatus"];
                dto.MachineID      = (string)reader["MachineID"];

                dto.BranchCode = oBranchInfoDTO;
                dto.BranchCode.BranchTypeInfoDTO = oBranchTypeInfoDTO;


                return(dto);
            }
            catch (Exception Exp)
            {
                throw Exp;
            }
        }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (this.lblErrorMessage.Text.Length != 0)
        {
            this.lblErrorMessage.Text = "";
        }

        if (this.txtBranchName.Text.Length == 0)
        {
            this.lblErrorMessage.Text = "Branch Name field can not be blank. Please Insert";
            txtBranchName.Focus();
            return;
        }

        else if (this.txtBranchAddress.Text.Length == 0)
        {
            this.lblErrorMessage.Text = "Branch Address field can not be blank. Please Insert";
            this.txtBranchAddress.Focus();
            return;
        }
        else if (this.txtCashInSafeLimit.Text.Length == 0)
        {
            this.lblErrorMessage.Text = "Cash In Safe Limit field can not be blank.You must enter a number.";
            this.txtCashInSafeLimit.Focus();
            return;
        }

        try
        {
            BranchInfoDTO brdto = Populate();

            IBranchInfoBL brFacade = Facade.GetInstance().createBranchBL();
            brFacade.addNewBranch(brdto);
            this.lblErrorMessage.Text = "Data Save Successfully.";
            this.txtBR_PK.Value       = "";


            int    codeno = 0;
            string num;
            int    brcodeno = Convert.ToInt32(brdto.BranchCode);
            codeno = (brcodeno + 1);
            num    = codeno.ToString("000");
            GridView1.DataBind();
        }
        catch (Exception Exp)
        {
            lblErrorMessage.Text = cls.ErrorString(Exp);
        }

        finally
        {
            Initilize_Page_Control();
        }
    }
    protected void GridView1_RowEditing(object sender, GridViewCommandEventArgs e)
    {
        try
        {
            if (e.CommandName == "Edit")
            {
                BranchInfoDTO odto = new BranchInfoDTO();

                int         index = Convert.ToInt32(e.CommandArgument);
                GridViewRow row   = GridView1.Rows[index];

                DataKey dk = GridView1.DataKeys[index];
                this.txtBR_PK.Value = dk.Value.ToString();

                Facade facade = Facade.GetInstance();
                odto = facade.getBranchInfoDTO((Guid)TypeDescriptor.GetConverter(odto.PrimaryKey).ConvertFromString(this.txtBR_PK.Value));

                this.txtBranchCode.Text = odto.BranchCode;

                BranchTypeInfoDTO btDto = new BranchTypeInfoDTO();
                btDto = facade.getBranchTypeInfo((Guid)odto.BT_PK);
                if (btDto.PrimaryKey.ToString() == "00000000-0000-0000-0000-000000000000")
                {
                    this.ddlBranchType.SelectedValue = "";
                }
                else
                {
                    this.ddlBranchType.SelectedValue = btDto.PrimaryKey.ToString();
                }

                this.txtBranchName.Text         = odto.BranchName;
                this.txtContactPerson.Text      = odto.ContactPerson;
                this.txtContactPersonPhone.Text = odto.ContactPersonPhone;
                this.txtBranchPrefix.Text       = odto.BranchPrefix;
                this.txtBranchAddress.Text      = odto.BranchAddress;
                this.txtTelephone1.Text         = odto.Telephone1;
                this.txtTelephone2.Text         = odto.Telephone2;
                this.txtTelephone3.Text         = odto.Telephone3;
                this.txtFax.Text             = odto.Fax;
                this.txtEMail.Text           = odto.EMail;
                this.txtCashInSafeLimit.Text = odto.CashInSafeLimit.ToString();
                this.btnAdd.Text             = "Update";
                this.txtBranchName.Focus();

                //this.Text = Server.HtmlDecode(row.Cells[].Text);
            }
        }
        catch (Exception Exp)
        {
            lblErrorMessage.Text = cls.ErrorString(Exp);
        }
    }
Beispiel #8
0
        public BranchInfoDTO findByPK(Guid pk)
        {
            BranchInfoDTO oBranchInfoDTO = new BranchInfoDTO();

            string sqlSelect = "Select BR_PK,BT_PK,BranchCode,BranchName,ContactPerson,ContactPersonPhone,BranchPrefix,BranchAddress,Telephone1,Telephone2,Telephone3,Fax,EMail,CashInSafeLimit,EntryBy,EntryDate From BranchInfo where BR_PK=@BR_PK";

            SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["DPOSConnectionString"].ToString());
            SqlCommand    objCmd  = sqlConn.CreateCommand();

            try
            {
                objCmd.CommandText = sqlSelect;
                objCmd.Connection  = sqlConn;

                objCmd.Parameters.Add("@BR_PK", SqlDbType.UniqueIdentifier, 16);

                objCmd.Parameters["@BR_PK"].Value = pk;

                sqlConn.Open();
                SqlDataReader thisReader = objCmd.ExecuteReader();

                while (thisReader.Read())
                {
                    oBranchInfoDTO = populate(thisReader);
                }

                thisReader.Close();
                thisReader.Dispose();
            }
            catch (Exception Exp)
            {
                throw Exp;
            }

            finally
            {
                objCmd.Dispose();
                objCmd.Cancel();
                sqlConn.Dispose();
                sqlConn.Close();
            }
            return(oBranchInfoDTO);
        }
Beispiel #9
0
    protected void GridView1_RowEdting(object sender, GridViewCommandEventArgs e)
    {
        try
        {
            if (e.CommandName == "Edit")
            {
                BoothInfoDTO oBoothInfoDTO = new BoothInfoDTO();

                int index = Convert.ToInt32(e.CommandArgument);

                GridViewRow row = GridView1.Rows[index];

                DataKey xx = this.GridView1.DataKeys[index];
                this.txtHideFieldPK.Value = xx.Value.ToString();

                Facade facade = Facade.GetInstance();
                oBoothInfoDTO               = facade.getBoothInfoDTO((Guid)TypeDescriptor.GetConverter(oBoothInfoDTO.PrimaryKey).ConvertFromString(this.txtHideFieldPK.Value));
                this.txtCashLimit.Text      = oBoothInfoDTO.BoothCashLimit.ToString();
                this.chkBoothStatus.Checked = oBoothInfoDTO.BoothStatus;

                BranchInfoDTO bDto = new BranchInfoDTO();
                bDto = facade.getBranchInfoDTO((Guid)oBoothInfoDTO.BR_PK);
                if (bDto.PrimaryKey.ToString() == "00000000-0000-0000-0000-000000000000")
                {
                    this.ddlBranchName.SelectedValue = "";
                }
                else
                {
                    this.ddlBranchName.SelectedValue = bDto.PrimaryKey.ToString();
                }
                this.lblErrorMessage.Text = "";
                this.btnSave.Text         = "Update";
            }
        }
        catch (Exception Exp)
        {
            lblErrorMessage.Text = cls.ErrorString(Exp);
        }
    }
Beispiel #10
0
        public List <BranchInfoDTO> GetBranchInfo()
        {
            List <BranchInfoDTO> productUnitList = new List <BranchInfoDTO>();

            SqlConnection objmycon = new SqlConnection(ConfigurationManager.ConnectionStrings["DPOSConnectionString"].ToString());
            SqlCommand    objcmd   = new SqlCommand();

            try
            {
                objcmd.Connection  = objmycon;
                objcmd.CommandText = "SELECT BR_PK,BT_PK,BranchCode,BranchName,ContactPerson,ContactPersonPhone,BranchPrefix,BranchAddress,Telephone1,Telephone2,Telephone3,Fax,EMail,CashInSafeLimit,EntryBy,EntryDate FROM BranchInfo ORDER BY BranchCode DESC";
                objmycon.Open();
                SqlDataReader thisReader = objcmd.ExecuteReader();

                while (thisReader.Read())
                {
                    BranchInfoDTO oProductUnitInfoDto = populate(thisReader);
                    productUnitList.Add(oProductUnitInfoDto);
                }

                thisReader.Close();
                thisReader.Dispose();
            }
            catch (Exception ex)
            {
                throw ex;
            }

            finally
            {
                objcmd.Dispose();
                objcmd.Cancel();
                objmycon.Close();
            }
            return(productUnitList);
        }
Beispiel #11
0
        public override void Save(object Obj)
        {
            BranchInfoDTO btInfo   = (BranchInfoDTO)Obj;
            SqlConnection objmycon = new SqlConnection(ConfigurationManager.ConnectionStrings["DPOSConnectionString"].ToString());

            try
            {
                SqlCommand objcmd = new SqlCommand();

                if (btInfo.PrimaryKey.ToString() == "00000000-0000-0000-0000-000000000000")
                {
                    btInfo.BranchCode = Get_BranchInfoCode(btInfo);

                    objcmd.CommandText = "Insert Into BranchInfo(BT_PK,BranchCode,BranchName,ContactPerson,ContactPersonPhone,BranchPrefix,BranchAddress,Telephone1,Telephone2,Telephone3,Fax,EMail,CashInSafeLimit,EntryBy,EntryDate) Values(@BT_PK,@BranchCode,@BranchName,@ContactPerson,@ContactPersonPhone,@BranchPrefix,@BranchAddress,@Telephone1,@Telephone2,@Telephone3,@Fax,@EMail,@CashInSafeLimit,@EntryBy,@EntryDate)";

                    objcmd.Parameters.Add(new SqlParameter("@BT_PK", SqlDbType.UniqueIdentifier, 16));
                    objcmd.Parameters.Add(new SqlParameter("@BranchCode", SqlDbType.VarChar, 3));
                    objcmd.Parameters.Add(new SqlParameter("@BranchName", SqlDbType.VarChar, 50));
                    objcmd.Parameters.Add(new SqlParameter("@ContactPerson", SqlDbType.VarChar, 50));
                    objcmd.Parameters.Add(new SqlParameter("@ContactPersonPhone", SqlDbType.VarChar, 15));
                    objcmd.Parameters.Add(new SqlParameter("@BranchPrefix", SqlDbType.VarChar, 3));
                    objcmd.Parameters.Add(new SqlParameter("@BranchAddress", SqlDbType.VarChar, 150));
                    objcmd.Parameters.Add(new SqlParameter("@Telephone1", SqlDbType.VarChar, 15));
                    objcmd.Parameters.Add(new SqlParameter("@Telephone2", SqlDbType.VarChar, 15));
                    objcmd.Parameters.Add(new SqlParameter("@Telephone3", SqlDbType.VarChar, 15));
                    objcmd.Parameters.Add(new SqlParameter("@Fax", SqlDbType.VarChar, 25));
                    objcmd.Parameters.Add(new SqlParameter("@EMail", SqlDbType.VarChar, 25));
                    objcmd.Parameters.Add(new SqlParameter("@CashInSafeLimit", SqlDbType.VarChar, 9));
                    //objcmd.Parameters.Add(new SqlParameter("@", SqlDbType.VarChar, ));

                    objcmd.Parameters.Add(new SqlParameter("@EntryBy", SqlDbType.VarChar, 5));
                    objcmd.Parameters.Add(new SqlParameter("@EntryDate", SqlDbType.DateTime, 8));

                    objcmd.Parameters["@BT_PK"].Value              = (Guid)btInfo.BT_PK;
                    objcmd.Parameters["@BranchCode"].Value         = (string)btInfo.BranchCode;
                    objcmd.Parameters["@BranchName"].Value         = (string)btInfo.BranchName;
                    objcmd.Parameters["@ContactPerson"].Value      = (string)btInfo.ContactPerson;
                    objcmd.Parameters["@ContactPersonPhone"].Value = (string)btInfo.ContactPersonPhone;
                    objcmd.Parameters["@BranchPrefix"].Value       = (string)btInfo.BranchPrefix;
                    objcmd.Parameters["@BranchAddress"].Value      = (string)btInfo.BranchAddress;
                    objcmd.Parameters["@Telephone1"].Value         = (string)btInfo.Telephone1;
                    objcmd.Parameters["@Telephone2"].Value         = (string)btInfo.Telephone2;
                    objcmd.Parameters["@Telephone3"].Value         = (string)btInfo.Telephone3;
                    objcmd.Parameters["@Fax"].Value             = (string)btInfo.Fax;
                    objcmd.Parameters["@EMail"].Value           = (string)btInfo.EMail;
                    objcmd.Parameters["@CashInSafeLimit"].Value = (Decimal)btInfo.CashInSafeLimit;

                    //objcmd.Parameters["@"].Value = (string)brInfo.

                    objcmd.Parameters["@EntryBy"].Value   = (string)btInfo.EntryBy;
                    objcmd.Parameters["@EntryDate"].Value = (DateTime)btInfo.EntryDate;
                }
                else
                {
                    objcmd.CommandText = "Update BranchInfo set BT_PK=@BT_PK, BranchName=@BranchName,ContactPerson=@ContactPerson,ContactPersonPhone=@ContactPersonPhone,BranchPrefix=@BranchPrefix,BranchAddress=@BranchAddress,Telephone1=@Telephone1,Telephone2=@Telephone2,Telephone3=@Telephone3,Fax=@Fax,EMail=@EMail,CashInSafeLimit=@CashInSafeLimit where BR_PK=@BR_PK";
                    objcmd.Parameters.Add(new SqlParameter("@BR_PK", SqlDbType.UniqueIdentifier, 16));
                    objcmd.Parameters.Add(new SqlParameter("@BT_PK", SqlDbType.UniqueIdentifier, 16));
                    objcmd.Parameters.Add(new SqlParameter("@BranchName", SqlDbType.VarChar, 50));
                    objcmd.Parameters.Add(new SqlParameter("@ContactPerson", SqlDbType.VarChar, 50));
                    objcmd.Parameters.Add(new SqlParameter("@ContactPersonPhone", SqlDbType.VarChar, 15));
                    objcmd.Parameters.Add(new SqlParameter("@BranchPrefix", SqlDbType.VarChar, 3));
                    objcmd.Parameters.Add(new SqlParameter("@BranchAddress", SqlDbType.VarChar, 150));
                    objcmd.Parameters.Add(new SqlParameter("@Telephone1", SqlDbType.VarChar, 15));
                    objcmd.Parameters.Add(new SqlParameter("@Telephone2", SqlDbType.VarChar, 15));
                    objcmd.Parameters.Add(new SqlParameter("@Telephone3", SqlDbType.VarChar, 15));
                    objcmd.Parameters.Add(new SqlParameter("@Fax", SqlDbType.VarChar, 25));
                    objcmd.Parameters.Add(new SqlParameter("@EMail", SqlDbType.VarChar, 25));
                    objcmd.Parameters.Add(new SqlParameter("@CashInSafeLimit", SqlDbType.Decimal, 9));


                    objcmd.Parameters["@BR_PK"].Value              = (Guid)btInfo.PrimaryKey;
                    objcmd.Parameters["@BT_PK"].Value              = (Guid)btInfo.BT_PK;
                    objcmd.Parameters["@BranchName"].Value         = (string)btInfo.BranchName;
                    objcmd.Parameters["@ContactPerson"].Value      = (string)btInfo.ContactPerson;
                    objcmd.Parameters["@ContactPersonPhone"].Value = (string)btInfo.ContactPersonPhone;
                    objcmd.Parameters["@BranchPrefix"].Value       = (string)btInfo.BranchPrefix;
                    objcmd.Parameters["@BranchAddress"].Value      = (string)btInfo.BranchAddress;
                    objcmd.Parameters["@Telephone1"].Value         = (string)btInfo.Telephone1;
                    objcmd.Parameters["@Telephone2"].Value         = (string)btInfo.Telephone2;
                    objcmd.Parameters["@Telephone3"].Value         = (string)btInfo.Telephone3;
                    objcmd.Parameters["@Fax"].Value             = (string)btInfo.Fax;
                    objcmd.Parameters["@EMail"].Value           = (string)btInfo.EMail;
                    objcmd.Parameters["@CashInSafeLimit"].Value = (Decimal)btInfo.CashInSafeLimit;
                }

                objcmd.Connection = objmycon;
                objmycon.Open();
                objcmd.ExecuteNonQuery();
            }
            catch (Exception Exp)
            {
                throw Exp;
            }
            finally
            {
                objmycon.Close();
            }
        }