示例#1
0
 protected void lvBrand_ItemCommand(object sender, ListViewCommandEventArgs e)
 {
     if (e.CommandName == "EditBrand")
     {
         try
         {
             labelMessage.Text = string.Empty;
             btnSave.Visible   = false;
             btnUpdate.Visible = true;
             btnDelete.Visible = true;
             btnCancel.Visible = true;
             long brandID = Convert.ToInt32(e.CommandArgument);
             hdBrandID.Value = brandID.ToString();
             using (BrandRT receiverTransfer = new BrandRT())
             {
                 Brand brand = receiverTransfer.GetBrandByID(brandID);
                 FillBrandForEdit(brand);
             }
         }
         catch (Exception ex)
         {
             labelMessage.Text      = "Error : " + ex.Message;
             labelMessage.ForeColor = System.Drawing.Color.Red;
         }
     }
 }
示例#2
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                labelMessage.Text = string.Empty;
                using (BrandRT receiverTransfer = new BrandRT())
                {
                    hdIsDelete.Value = "true";
                    hdIsEdit.Value   = "true";
                    Brand brand = CreateBrand();

                    if (brand != null)
                    {
                        receiverTransfer.UpdateBrand(brand);
                        labelMessage.Text      = "Data successfully deleted...";
                        labelMessage.ForeColor = System.Drawing.Color.Green;
                    }
                    else
                    {
                        labelMessage.Text      = "Data not deleted...";
                        labelMessage.ForeColor = System.Drawing.Color.Red;
                    }
                }
                LoadBrandListView();
                ClearField();
            }
            catch (Exception ex)
            {
                labelMessage.Text      = "Error : " + ex.Message;
                labelMessage.ForeColor = System.Drawing.Color.Red;
            }
        }
示例#3
0
 private void LoadBrandListView()
 {
     try
     {
         using (BrandRT receiverTransfer = new BrandRT())
         {
             lvBrand.DataSource = receiverTransfer.GetBrandForListView();
             lvBrand.DataBind();
         }
     }
     catch (Exception ex)
     {
         labelMessage.Text      = "Error : " + ex.Message;
         labelMessage.ForeColor = System.Drawing.Color.Red;
     }
 }
示例#4
0
        private void FillModelForEdit(Model model)
        {
            try
            {
                if (model != null)
                {
                    BrandRT recTransfer = new BrandRT();
                    txtBrandID.Text   = model.BrandID.ToString();
                    txtModelName.Text = model.Name;

                    txtBrandName.Text  = Convert.ToString(recTransfer.GetBrandByID(Convert.ToInt64(model.BrandID)).Name);
                    Session[sessModel] = model;
                }
            }
            catch (Exception ex)
            {
                labelMessage.Text      = "Error : " + ex.Message;
                labelMessage.ForeColor = System.Drawing.Color.Red;
            }
        }
示例#5
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                labelMessage.Text = string.Empty;
                using (BrandRT receiverTransfer = new BrandRT())
                {
                    hdIsEdit.Value = "true";
                    Brand brand = CreateBrand();

                    if (brand != null)
                    {
                        if (receiverTransfer.IsBrandNameExistInOterRows(brand.IID, brand.Name, brand.Origin))
                        {
                            labelMessage.Text      = "Brand Name " + txtBrandName.Text + " Already Exist!";
                            labelMessage.ForeColor = System.Drawing.Color.Red;
                            return;
                        }

                        receiverTransfer.UpdateBrand(brand);
                        labelMessage.Text      = "Data successfully updated...";
                        labelMessage.ForeColor = System.Drawing.Color.Green;
                    }
                    else
                    {
                        labelMessage.Text      = "Data not updated...";
                        labelMessage.ForeColor = System.Drawing.Color.Red;
                    }
                }
                ClearField();
                SetButton();
                LoadBrandListView();
            }
            catch (Exception ex)
            {
                labelMessage.Text      = "Error : " + ex.Message;
                labelMessage.ForeColor = System.Drawing.Color.Red;
            }
        }
示例#6
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                labelMessage.Text = string.Empty;
                using (BrandRT receiverTransfer = new BrandRT())
                {
                    int originID = int.Parse(txtOriginID.Text);

                    if (receiverTransfer.IsBrandNameExists(txtBrandName.Text, originID))
                    {
                        labelMessage.Text      = "Brand Name " + txtBrandName.Text + " Already Exists !";
                        labelMessage.ForeColor = System.Drawing.Color.Red;
                        return;
                    }

                    Brand brand = CreateBrand();
                    receiverTransfer.AddBrand(brand);
                    if (brand.IID > 0)
                    {
                        labelMessage.Text      = "Data successfully saved...";
                        labelMessage.ForeColor = System.Drawing.Color.Green;
                    }
                    else
                    {
                        labelMessage.Text      = "Data not saved...";
                        labelMessage.ForeColor = System.Drawing.Color.Red;
                    }
                }
                ClearField();
                LoadBrandListView();
            }
            catch (Exception ex)
            {
                labelMessage.Text      = "Error : " + ex.Message;
                labelMessage.ForeColor = System.Drawing.Color.Red;
            }
        }
示例#7
0
        private void FillMaterialFormForEdit(Int64 materialIID)
        {
            try
            {
                using (MaterialRT rt = new MaterialRT())
                {
                    hdMaterialID.Value = materialIID.ToString();

                    Material material = rt.GetMaterialByIID(materialIID);

                    if (material == null)
                    {
                        Response.Redirect("~/ManageYourAds.aspx");
                    }

                    if (!(material.BrandID == 0 || material.BrandID == null))
                    {
                        txtBrandID.Text = material.BrandID.ToString();
                        using (BrandRT brandRt = new BrandRT())
                        {
                            txtBrand.Text = brandRt.GetBrandByID((long)material.BrandID).Name;
                        }
                    }

                    if (!(material.ModelID != 0 || material.ModelID != null))
                    {
                        using (ModelRT aModelRt = new ModelRT())
                        {
                            txtModel.Text = aModelRt.GetModelByID((int)material.ModelID).Name;
                        }
                    }

                    if (!(material.ColorID != 0 || material.ColorID != null))
                    {
                        using (ColorRT aColorRt = new ColorRT())
                        {
                            txtModel.Text = aColorRt.GetColorByID((int)material.ColorID).Name;
                        }
                    }

                    using (AdGiverRT adGiverRt = new AdGiverRT())
                    {
                        txtUserID.Text = material.AdGiverID != 0 ? adGiverRt.GetAdGiverByIID((long)material.AdGiverID).EmailID : string.Empty;
                    }
                    txtTitleName.Text = material.TitleName;
                    txtPrice.Text     = material.Price.ToString();

                    txtDescription.Text   = material.Description;
                    txtCode.Text          = material.Code;
                    txtWeburl.Text        = material.WebSiteUrl;
                    txtYoutubeUrl.Text    = material.YoutubeUrl;
                    txtPhoneNumber.Text   = material.UserPhoneNumber;
                    chkNegotiable.Checked = material.IsNegotiablePrice;

                    dropDownCategory.SelectedValue = material.CategoryID.ToString();



                    using (LocationRT aLocationRt = new LocationRT())
                    {
                        txtLocationID.Text = material.LocationID.ToString();

                        long   districtID = 0, policeStationID = 0;
                        string districtName = string.Empty, polStationName = string.Empty, locationName = string.Empty;
                        bool   isReceiveInfo = aLocationRt.GetLocationInfoByIID(material.LocationID, ref districtID, ref districtName, ref policeStationID, ref polStationName, ref locationName);
                        if (isReceiveInfo)
                        {
                            txtDistrictID.Text      = districtID.ToString();
                            txtDistrict.Text        = districtName.ToString();
                            txtPoliceStationID.Text = policeStationID.ToString();
                            txtPoliceStation.Text   = polStationName.ToString();
                            txtLocation.Text        = locationName.ToString();
                        }
                    }

                    DateTime addDate            = material.AdDate;
                    DateTime adDisplayLastDate  = (DateTime)(material.AdDisplayLastDate ?? material.AdDate);
                    int      adDisplayTotalDate = (int)(adDisplayLastDate - addDate).TotalDays;
                    txtPostVisibilityDay.Text = adDisplayTotalDate.ToString();


                    List <ControlAdmin.MaterialWF.ImageUrl> matPicTempFileUrlList = new List <ControlAdmin.MaterialWF.ImageUrl>();
                    using (PictureRT aPictureRt = new PictureRT())
                    {
                        List <Picture> picList = new List <Picture>();
                        picList = aPictureRt.GetPictureByMaterialIID(Convert.ToInt64(materialIID));

                        if (picList.Count > 0)
                        {
                            foreach (var picture in picList)
                            {
                                ControlAdmin.MaterialWF.ImageUrl aImageUrl = new ControlAdmin.MaterialWF.ImageUrl();
                                aImageUrl.ImageUrlTemp = picture.UrlAddress;
                                matPicTempFileUrlList.Add(aImageUrl);
                            }
                        }
                    }
                    Session["seMatPicTempFileName"] = matPicTempFileUrlList;
                    datalistMatPic.DataSource       = matPicTempFileUrlList;
                    datalistMatPic.DataBind();

                    Session[sessMaterial] = material;
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }