コード例 #1
0
        private string Get_NewProductBrandCode(ProductBrandInfoDTO dto)
        {
            string        pbCode   = null;
            int           pbCodeNo = 0;
            SqlConnection objMyCon = new SqlConnection(ConfigurationManager.ConnectionStrings["DPOSConnectionString"].ToString());
            SqlCommand    objCmd   = new SqlCommand();

            objCmd.CommandText = "Select Isnull(Max(cast(PB_Code as int)),0 )+1 From ProductBrandInfo";
            try
            {
                objMyCon.Open();
                objCmd.Connection = objMyCon;
                pbCodeNo          = (int)objCmd.ExecuteScalar();
            }
            catch (Exception Exp)
            {
                throw Exp;
            }
            finally
            {
                objMyCon.Close();
            }

            pbCode = pbCodeNo.ToString("0000");
            return(pbCode);
        }
コード例 #2
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (this.lblErrorMessage.Text.Length != 0)
        {
            this.lblErrorMessage.Text = "";
        }

        if (this.txtBrandName.Text.Length == 0)
        {
            this.lblErrorMessage.Text = "* Invalid Brand Name";
            return;
        }

        ProductBrandInfoDTO pbDto = Populate();

        try
        {
            IProductBrandBL pbFacade = Facade.GetInstance().GetPBBlImp();
            pbFacade.AddProductBrand(pbDto);

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

            this.hfPrimaryKey.Value = "";
            this.txtBrandCode.Text  = "";
            this.txtBrandName.Text  = "";
            this.btnAdd.Text        = "Save";
            GridView1.DataBind();
        }
        catch (Exception Exp)
        {
            lblErrorMessage.Text = cls.ErrorString(Exp);
        }
    }
コード例 #3
0
        public override void Delete(object PrimaryKey)
        {
            ProductBrandInfoDTO dto = (ProductBrandInfoDTO)PrimaryKey;

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

            objCmd.CommandText = "Delete From ProductBrandInfo Where PB_PK=@PB_PK";
            objCmd.Parameters.Add(new SqlParameter("@PB_PK", SqlDbType.UniqueIdentifier, 16));
            objCmd.Parameters["@PB_PK"].Value = (Guid)dto.PrimaryKey;

            objCmd.Connection = objMyCon;
            try
            {
                objMyCon.Open();
                objCmd.ExecuteNonQuery();
            }
            catch (Exception Exp)
            {
                throw Exp;
            }
            finally
            {
                objMyCon.Close();
            }
        }
コード例 #4
0
        public ArrayList GetData()
        {
            SqlConnection objMyCon  = new SqlConnection(ConfigurationManager.ConnectionStrings["DPOSConnectionString"].ToString());
            SqlCommand    objCom    = new SqlCommand();
            ArrayList     brandList = new ArrayList();
            SqlDataReader reader;

            objCom.Connection  = objMyCon;
            objCom.CommandText = "SELECT PB_PK, PB_Code, PB_Name FROM ProductBrandInfo ORDER BY PB_Code DESC";

            try
            {
                objMyCon.Open();
                reader = objCom.ExecuteReader();
            }
            catch (Exception Exp)
            {
                throw Exp;
            }
            while (reader.Read())
            {
                ProductBrandInfoDTO dto = Populate(reader);
                brandList.Add(dto);
            }

            reader.Close();
            reader.Dispose();

            return(brandList);
        }
コード例 #5
0
        public List <ProductBrandInfoDTO> GetProductBrand()
        {
            List <ProductBrandInfoDTO> productBrandiList = new List <ProductBrandInfoDTO>();
            SqlDataReader DR;
            SqlConnection objMyCon = new SqlConnection(ConfigurationManager.ConnectionStrings["DPOSConnectionString"].ToString());
            SqlCommand    objCmd   = new SqlCommand();

            objCmd.Connection  = objMyCon;
            objCmd.CommandText = "SELECT PB_PK, PB_Code, PB_Name FROM ProductBrandInfo ORDER BY PB_Code DESC";

            try
            {
                objMyCon.Open();
                DR = objCmd.ExecuteReader();
            }
            catch (Exception Exp)
            {
                throw Exp;
            }
            while (DR.Read())
            {
                ProductBrandInfoDTO pbDto = new ProductBrandInfoDTO();//(Guid)DR[0],(string)DR[1],(string)DR[1]);

                pbDto.PrimaryKey = (Guid)DR[0];
                pbDto.PB_Code    = (string)DR[1];
                pbDto.PB_Name    = (string)DR[2];
                productBrandiList.Add(pbDto);
            }

            DR.Close();
            objMyCon.Close();
            return(productBrandiList);
        }
コード例 #6
0
        public override void Save(object Obj)
        {
            ProductBrandInfoDTO dto = (ProductBrandInfoDTO)Obj;

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

            if (dto.PrimaryKey.ToString() == "00000000-0000-0000-0000-000000000000")
            {
                dto.PB_Code = Get_NewProductBrandCode(dto);

                objCmd.CommandText = "Insert Into ProductBrandInfo(PB_Code,PB_Name,EntryBy,EntryDate) Values(@PB_Code,@PB_Name,@EntryBy,@EntryDate)";
                objCmd.Parameters.Add(new SqlParameter("@PB_Code", SqlDbType.VarChar, 4));
                objCmd.Parameters.Add(new SqlParameter("@PB_Name", SqlDbType.VarChar, 50));

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

                objCmd.Parameters["@PB_Code"].Value = (string)dto.PB_Code;
                objCmd.Parameters["@PB_Name"].Value = (string)dto.PB_Name;

                objCmd.Parameters["@Entryby"].Value   = (string)dto.EntryBy;
                objCmd.Parameters["@EntryDate"].Value = (DateTime)dto.EntryDate;
            }
            else
            {
                objCmd.CommandText = "Update ProductBrandInfo Set PB_Name=@PB_Name Where PB_PK=@PB_PK";
                objCmd.Parameters.Add(new SqlParameter("@PB_PK", SqlDbType.UniqueIdentifier, 16));
                objCmd.Parameters.Add(new SqlParameter("@PB_Name", SqlDbType.VarChar, 50));
                objCmd.Parameters["@PB_PK"].Value   = (Guid)dto.PrimaryKey;
                objCmd.Parameters["@PB_Name"].Value = (string)dto.PB_Name;
            }
            try
            {
                objCmd.Connection = objMyCon;
                objMyCon.Open();
                objCmd.ExecuteNonQuery();
            }
            catch (Exception Exp)
            {
                throw Exp;
            }
            finally
            {
                objMyCon.Close();
            }
        }
コード例 #7
0
        public ProductBrandInfoDTO Populate(SqlDataReader reader)
        {
            try
            {
                ProductBrandInfoDTO dto = new ProductBrandInfoDTO();

                dto.PrimaryKey = (Guid)reader["PB_PK"];
                dto.PB_Code    = (string)reader["PB_Code"];
                dto.PB_Name    = (string)reader["PB_Name"];

                return(dto);
            }
            catch (Exception Exp)
            {
                throw Exp;
            }
        }
コード例 #8
0
    /// <summary>
    /// Set all information in Domain Object
    /// </summary>
    /// <returns></returns>
    private ProductBrandInfoDTO Populate()
    {
        try
        {
            ProductBrandInfoDTO pbDto = new ProductBrandInfoDTO();
            if (this.hfPrimaryKey.Value.ToString() != "")
            {
                pbDto.PrimaryKey = (Guid)TypeDescriptor.GetConverter(pbDto.PrimaryKey).ConvertFromString(this.hfPrimaryKey.Value);
            }

            pbDto.PB_Code   = this.txtBrandCode.Text;
            pbDto.PB_Name   = this.txtBrandName.Text;
            pbDto.EntryBy   = Constants.DEFULT_USER;
            pbDto.EntryDate = DateTime.Today;

            return(pbDto);
        }
        catch (Exception Exp)
        {
            throw Exp;
        }
    }
コード例 #9
0
        public ProductBrandInfoDTO FindByPK(Guid pk)
        {
            ProductBrandInfoDTO pbDTO = new ProductBrandInfoDTO();
            string        sqlSelect   = "SELECT PB_PK, PB_Code, PB_Name FROM ProductBrandInfo WHERE PB_PK=@PB_PK";
            SqlConnection sqlConn     = new SqlConnection(ConfigurationManager.ConnectionStrings["DPOSConnectionString"].ToString());
            SqlCommand    objCmd      = sqlConn.CreateCommand();

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

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

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

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

            finally
            {
                objCmd.Dispose();
                objCmd.Cancel();
                sqlConn.Dispose();
                sqlConn.Close();
            }
            return(pbDTO);
        }
コード例 #10
0
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        try
        {
            int         index = e.RowIndex;
            GridViewRow row   = GridView1.Rows[index];

            ProductBrandInfoDTO pbDto = new ProductBrandInfoDTO();

            DataKey dk = GridView1.DataKeys[index];
            this.hfPrimaryKey.Value = dk.Value.ToString();
            pbDto.PrimaryKey        = (Guid)TypeDescriptor.GetConverter(pbDto.PrimaryKey).ConvertFromString(this.hfPrimaryKey.Value);

            IProductBrandBL pbFacade = Facade.GetInstance().GetPBBlImp();
            pbFacade.DelProductBrand(pbDto);
            this.hfPrimaryKey.Value = "";
            GridView1.DataBind();
        }
        catch (Exception Exp)
        {
            lblErrorMessage.Text = cls.ErrorString(Exp);
        }
    }
コード例 #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);
        }
    }