Exemple #1
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            if (this.lblErrorMessage.Text.Length != 0)
            {
                this.lblErrorMessage.Text = "";
            }

            ProductSubCategoryInfoDTO dto = populate();

            Facade facade = Facade.GetInstance();
            IProductSubCategoryInfoBL oCategoryBL = facade.createProductSubCategoryBL();
            oCategoryBL.addNewProductSubCategory(dto);

            this.lblErrorMessage.Text = "Data Save Successfully.";

            this.GridView1.DataBind();


            this.txtHideFieldPK.Value             = "";
            this.txtPSCCode.Text                  = "";
            this.txtPSubCategoryDescription.Text  = "";
            this.ddlProductCategory.SelectedValue = "";
            this.btnSave.Text = "Save";
        }
        catch (Exception Exp)
        {
            lblErrorMessage.Text = cls.ErrorString(Exp);
        }
    }
Exemple #2
0
    /// <summary>
    /// Set All Information in Domain Class
    /// </summary>
    /// <returns></returns>
    public ProductSubCategoryInfoDTO  populate()
    {
        try
        {
            string strPC_PK;
            ProductSubCategoryInfoDTO dto = new ProductSubCategoryInfoDTO();
            // populate dto

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

            if (this.ddlProductCategory.SelectedValue == "00000000-0000-0000-0000-000000000000")
            {
                throw new Exception("Invalid category.");
            }

            dto.PSC_Description = this.txtPSubCategoryDescription.Text;
            strPC_PK            = (string)this.ddlProductCategory.SelectedValue;
            dto.PC_PK           = (Guid)TypeDescriptor.GetConverter(dto.PC_PK).ConvertFromString(strPC_PK);
            dto.EntryBy         = "Admin";
            dto.EntryDate       = DateTime.Now.Date;

            return(dto);
        }
        catch (Exception Exp)
        {
            throw Exp;
        }
    }
Exemple #3
0
        private void getPKCode(ProductSubCategoryInfoDTO obj)
        {
            SqlConnection sqlConn   = new SqlConnection(ConfigurationManager.ConnectionStrings["DPOSConnectionString"].ToString());
            string        strPKCode = null;
            int           PKSL      = 0;

            string sqlSelect = "Select isnull(Max(PSC_Code),0)+1 From ProductSubCategoryInfo";

            SqlCommand objCmd = sqlConn.CreateCommand();

            objCmd.CommandText = sqlSelect;

            try
            {
                sqlConn.Open();
                PKSL = (int)objCmd.ExecuteScalar();
            }
            catch (Exception Exp)
            {
                throw Exp;
            }
            finally
            {
                objCmd.Dispose();
                objCmd.Cancel();
                sqlConn.Dispose();
                sqlConn.Close();
            }

            strPKCode    = PKSL.ToString("000");
            obj.PSC_Code = strPKCode;
            //return strPKCode;
        }
Exemple #4
0
        public override void Delete(object obj)
        {
            ProductSubCategoryInfoDTO oProductSubCategoryInfoDTO = (ProductSubCategoryInfoDTO)obj;

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

            String sql = "Delete  ProductSubCategoryInfo where PSC_PK=@PSC_PK";

            SqlCommand objCmdDelete = sqlConn.CreateCommand();

            objCmdDelete.CommandText = sql;

            try
            {
                objCmdDelete.Parameters.Add("@PSC_PK", SqlDbType.UniqueIdentifier, 16);

                objCmdDelete.Parameters["@PSC_PK"].Value = (Guid)oProductSubCategoryInfoDTO.PrimaryKey;

                sqlConn.Open();
                objCmdDelete.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                objCmdDelete.Dispose();
                objCmdDelete.Cancel();
                sqlConn.Dispose();
                sqlConn.Close();
            }
        }
Exemple #5
0
        /// <summary>
        /// Set All data in Domain()
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        public ProductSubCategoryInfoDTO Populate(SqlDataReader reader)
        {
            try
            {
                ProductSubCategoryInfoDTO dto = new ProductSubCategoryInfoDTO();

                dto.PrimaryKey      = (Guid)reader["PSC_PK"];
                dto.PC_PK           = (Guid)reader["PC_PK"];
                dto.PSC_Code        = (string)reader["PSC_Code"];
                dto.PSC_Description = (string)reader["PSC_Description"];
                dto.EntryBy         = (string)reader["EntryBy"];
                dto.EntryDate       = (DateTime)reader["EntryDate"];
                return(dto);
            }
            catch (Exception Exp)
            {
                throw Exp;
            }
        }
Exemple #6
0
        /// <summary>
        /// Get Product Category all Information
        /// </summary>
        /// <returns></returns>
        public List <ProductSubCategoryInfoDTO> getProductSubCategoryData()
        {
            string sqlSelect = "Select PSC_PK,PC_PK,PSC_Code,PSC_Description,EntryBy,EntryDate From ProductSubCategoryInfo order by PSC_Code DESC";

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

            List <ProductSubCategoryInfoDTO> oArrayList = new List <ProductSubCategoryInfoDTO>();

            SqlCommand objCmd = sqlConn.CreateCommand();

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

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

                while (thisReader.Read())
                {
                    ProductSubCategoryInfoDTO oProductSubCategoryInfoDTO = Populate(thisReader);
                    oArrayList.Add(oProductSubCategoryInfoDTO);
                }

                thisReader.Close();
                thisReader.Dispose();
            }
            catch (Exception Exp)
            {
                throw Exp;
            }
            finally
            {
                objCmd.Dispose();
                objCmd.Cancel();
                sqlConn.Dispose();
                sqlConn.Close();
            }
            return(oArrayList);
        }
Exemple #7
0
        /// <summary>
        /// Get Product Category Information corresponding definite Product Primary Key.
        /// </summary>
        /// <param name="pk"></param>
        /// <returns></returns>
        public ProductSubCategoryInfoDTO FindByPK(Guid pk)
        {
            ProductSubCategoryInfoDTO pscDTO = new ProductSubCategoryInfoDTO();
            string        sqlSelect          = "SELECT PSC_PK, PC_PK,PSC_Code, PSC_Description,EntryBy,EntryDate FROM ProductSubCategoryInfo WHERE PSC_PK=@PSC_PK";
            SqlConnection sqlConn            = new SqlConnection(ConfigurationManager.ConnectionStrings["DPOSConnectionString"].ToString());
            SqlCommand    objCmd             = sqlConn.CreateCommand();

            try
            {
                objCmd.CommandText = sqlSelect;
                objCmd.Connection  = sqlConn;
                objCmd.Parameters.Add("@PSC_PK", SqlDbType.UniqueIdentifier, 16);
                objCmd.Parameters["@PSC_PK"].Value = pk;

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

                while (thisReader.Read())
                {
                    pscDTO = Populate(thisReader);
                }

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

            finally
            {
                objCmd.Dispose();
                objCmd.Cancel();
                sqlConn.Dispose();
                sqlConn.Close();
            }
            return(pscDTO);
        }
Exemple #8
0
        /// <summary>
        /// Get Product Category Information corresponding definite Product Primary Key.
        /// </summary>
        /// <param name="pk"></param>
        /// <returns></returns>
        public List <ProductSubCategoryInfoDTO> getProductSubCategoryDataByPC(Guid pk)
        {
            string        sqlSelect = "Select PSC_PK,PC_PK,PSC_Code,PSC_Description,EntryBy,EntryDate From ProductSubCategoryInfo Where PC_PK=@PC_PK";
            SqlConnection sqlConn   = new SqlConnection(ConfigurationManager.ConnectionStrings["DPOSConnectionString"].ToString());
            List <ProductSubCategoryInfoDTO> oArrayList = new List <ProductSubCategoryInfoDTO>();
            SqlCommand objCmd = sqlConn.CreateCommand();

            try
            {
                objCmd.CommandText = sqlSelect;
                objCmd.Connection  = sqlConn;
                objCmd.Parameters.Add("@PC_PK", SqlDbType.UniqueIdentifier, 16);
                objCmd.Parameters["@PC_PK"].Value = pk;

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

                while (thisReader.Read())
                {
                    ProductSubCategoryInfoDTO oProductSubCategoryInfoDTO = Populate(thisReader);
                    oArrayList.Add(oProductSubCategoryInfoDTO);
                }

                thisReader.Close();
                thisReader.Dispose();
            }
            catch (Exception Exp)
            {
                throw Exp;
            }
            finally
            {
                objCmd.Dispose();
                objCmd.Cancel();
                sqlConn.Dispose();
                sqlConn.Close();
            }
            return(oArrayList);
        }
Exemple #9
0
    protected void GridView1_RowEdting(object sender, GridViewCommandEventArgs e)
    {
        try
        {
            if (e.CommandName == "Edit")
            {
                Facade facade = Facade.GetInstance();
                int    index  = Convert.ToInt32(e.CommandArgument);

                ProductSubCategoryInfoDTO oProductSubCategoryInfoDTO = new ProductSubCategoryInfoDTO();

                GridViewRow row = GridView1.Rows[index];

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

                oProductSubCategoryInfoDTO = facade.GetProductsubCategoryInfo((Guid)TypeDescriptor.GetConverter(oProductSubCategoryInfoDTO.PrimaryKey).ConvertFromString(this.txtHideFieldPK.Value));

                this.txtPSCCode.Text = Server.HtmlDecode(row.Cells[2].Text);
                this.txtPSubCategoryDescription.Text = Server.HtmlDecode(row.Cells[3].Text);
                this.btnSave.Text = "Update";

                ProductCategoryInfoDTO pcDto = new ProductCategoryInfoDTO();
                pcDto = facade.GetProductCategoryInfo((Guid)oProductSubCategoryInfoDTO.PC_PK);
                this.ddlProductCategory.SelectedValue = pcDto.PrimaryKey.ToString();

                //*********Modified by NERO. DDL Select Example. Req: SAMAD********************
                //DropDownList1.SelectedItem.Selected = false;
                //DropDownList1.Items.FindByValue("000111-222556-3333-2222-222").Selected=true;
                //*********END EXAMPLE*********************************************************
            }
        }
        catch (Exception Exp)
        {
            lblErrorMessage.Text = cls.ErrorString(Exp);
        }
    }
Exemple #10
0
        public override void Save(object obj)
        {
            ProductSubCategoryInfoDTO oProductSubCategoryInfoDTO = (ProductSubCategoryInfoDTO)obj;

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

            if (oProductSubCategoryInfoDTO.PrimaryKey.ToString() == "00000000-0000-0000-0000-000000000000")
            {
                //string strset = getPKCode(oProductCategoryInfoDTO);
                String sql = "Insert Into ProductSubCategoryInfo(PC_PK,PSC_Code,PSC_Description,EntryBy,EntryDate) values(@PC_PK,@PSC_Code,@PSC_Description,@EntryBy,@EntryDate)";

                try
                {
                    getPKCode(oProductSubCategoryInfoDTO);

                    objCmd.CommandText = sql;

                    objCmd.Parameters.Add(new SqlParameter("@PC_PK", SqlDbType.UniqueIdentifier, 16));
                    objCmd.Parameters.Add(new SqlParameter("@PSC_Code", SqlDbType.VarChar, 3));
                    objCmd.Parameters.Add(new SqlParameter("@PSC_Description", SqlDbType.VarChar, 50));
                    objCmd.Parameters.Add(new SqlParameter("@EntryBy", SqlDbType.VarChar, 5));
                    objCmd.Parameters.Add(new SqlParameter("@EntryDate", SqlDbType.DateTime));

                    objCmd.Parameters["@PC_PK"].Value           = (Guid)oProductSubCategoryInfoDTO.PC_PK;
                    objCmd.Parameters["@PSC_Code"].Value        = Convert.ToString(oProductSubCategoryInfoDTO.PSC_Code);
                    objCmd.Parameters["@PSC_Description"].Value = Convert.ToString(oProductSubCategoryInfoDTO.PSC_Description);
                    objCmd.Parameters["@EntryBy"].Value         = Convert.ToString(oProductSubCategoryInfoDTO.EntryBy);
                    objCmd.Parameters["@EntryDate"].Value       = Convert.ToDateTime(oProductSubCategoryInfoDTO.EntryDate);

                    sqlConn.Open();
                    objCmd.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    objCmd.Dispose();
                    objCmd.Cancel();
                    sqlConn.Close();
                    sqlConn.Dispose();
                }
            }
            else
            {
                String sql = "Update  ProductSubCategoryInfo set PC_PK=@PC_PK,PSC_Description=@PSC_Description,EntryBy=@EntryBy,EntryDate=@EntryDate where PSC_PK=@PSC_PK ";

                try
                {
                    objCmd.CommandText = sql;

                    objCmd.Parameters.Add(new SqlParameter("@PSC_PK", SqlDbType.UniqueIdentifier, 16));
                    objCmd.Parameters.Add(new SqlParameter("@PC_PK", SqlDbType.UniqueIdentifier, 16));
                    objCmd.Parameters.Add(new SqlParameter("@PSC_Description", SqlDbType.VarChar, 50));
                    objCmd.Parameters.Add(new SqlParameter("@EntryBy", SqlDbType.VarChar, 5));
                    objCmd.Parameters.Add(new SqlParameter("@EntryDate", SqlDbType.DateTime));

                    objCmd.Parameters["@PSC_PK"].Value          = (Guid)oProductSubCategoryInfoDTO.PrimaryKey;
                    objCmd.Parameters["@PC_PK"].Value           = (Guid)oProductSubCategoryInfoDTO.PC_PK;
                    objCmd.Parameters["@PSC_Description"].Value = Convert.ToString(oProductSubCategoryInfoDTO.PSC_Description);
                    objCmd.Parameters["@EntryBy"].Value         = Convert.ToString(oProductSubCategoryInfoDTO.EntryBy);
                    objCmd.Parameters["@EntryDate"].Value       = Convert.ToDateTime(oProductSubCategoryInfoDTO.EntryDate);

                    sqlConn.Open();
                    objCmd.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    objCmd.Dispose();
                    objCmd.Cancel();
                    sqlConn.Dispose();
                    sqlConn.Close();
                }
            }
        }
Exemple #11
0
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        try
        {
            if (e.CommandName == "Edit")
            {
                ProductInfoDTO pDto = new ProductInfoDTO();

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

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

                Facade facade = Facade.GetInstance();

                DropDownListSubCategory(facade);

                pDto = facade.GetProductInfoDTO((Guid)TypeDescriptor.GetConverter(pDto.PrimaryKey).ConvertFromString(this.hfPrimaryKey.Value));
                this.txtProductCode.Text    = pDto.P_Code;
                this.txtProductName.Text    = pDto.P_Name;
                this.txtStyle.Text          = pDto.P_Style;
                this.txtSalesPrice.Text     = pDto.P_SalesPrice.ToString();
                this.txtCostPrice.Text      = pDto.P_CostPrice.ToString();
                this.txtTax.Text            = pDto.P_Tax.ToString();
                this.txtVat.Text            = pDto.P_VAT.ToString();
                this.txtDiscount.Text       = pDto.P_Discount.ToString();
                this.txtMinLevel.Text       = pDto.P_MinLevel.ToString();
                this.txtMaxLevel.Text       = pDto.P_MaxLevel.ToString();
                this.txtReorderLevel.Text   = pDto.P_ReorderLevel.ToString();
                this.chkStatus.Checked      = pDto.P_Status;
                this.txtSalesPriceDate.Text = pDto.P_SalesPriceDate.ToString("MM/dd/yyyy");
                this.txtCostPriceDate.Text  = pDto.P_CostPriceDate.ToString("MM/dd/yyyy");
                this.chkWarranty.Checked    = pDto.P_Warranty;
                this.txtWarrantyMonth.Text  = pDto.P_WarrantyMonth.ToString();
                this.btnSave.Text           = "Update";

                ProductCategoryInfoDTO pcDto = new ProductCategoryInfoDTO();
                pcDto = facade.GetProductCategoryInfo((Guid)pDto.PC_PrimaryKey);
                this.ddlProductCategory.SelectedValue = pcDto.PrimaryKey.ToString();

                ProductSubCategoryInfoDTO pscDto = new ProductSubCategoryInfoDTO();
                pscDto = facade.GetProductsubCategoryInfo((Guid)pDto.PSC_PrimaryKey);
                if (pscDto.PrimaryKey.ToString() == "00000000-0000-0000-0000-000000000000")
                {
                    this.ddlProductSubCategory.SelectedValue = "";
                }
                else
                {
                    this.ddlProductSubCategory.SelectedValue = pscDto.PrimaryKey.ToString();
                }

                ProductBrandInfoDTO pbDto = new ProductBrandInfoDTO();
                pbDto = facade.GetProductBrandInfo((Guid)pDto.PB_PrimaryKey);
                if (pbDto.PrimaryKey.ToString() == "00000000-0000-0000-0000-000000000000")
                {
                    this.ddlProductBrand.SelectedValue = "";
                }
                else
                {
                    this.ddlProductBrand.SelectedValue = pbDto.PrimaryKey.ToString();
                }

                ProductUnitInfoDTO puDto = new ProductUnitInfoDTO();
                puDto = facade.GetProductUnitInfo((Guid)pDto.PU_PrimaryKey);
                if (puDto.PrimaryKey.ToString() == "00000000-0000-0000-0000-000000000000")
                {
                    this.ddlProductUnit.SelectedValue = "";
                }
                else
                {
                    this.ddlProductUnit.SelectedValue = puDto.PrimaryKey.ToString();
                }
            }
        }
        catch (Exception Exp)
        {
            lblErrorMessage.Text = cls.ErrorString(Exp);
        }
    }