Esempio n. 1
0
        protected void btnAddsku_Click(object sender, EventArgs e)
        {
            clsSku objsku = new clsSku();

            objsku.SkuName         = txtJGSku.Text;
            objsku.TotalCost       = Convert.ToSingle(txtTotalCost.Text == "" ? "0" : txtTotalCost.Text);
            objsku.UOM             = txtUOM.Text;
            objsku.Unit            = Convert.ToSingle(txtUnit.Text == "" ? "0" : txtUnit.Text);
            objsku.CostDescription = txtCostDesc.Text;
            objsku.VendorPart      = txtVendorPart.Text;
            objsku.Model           = txtModel.Text;
            string filename = "";

            if (fupSkuImage.HasFile)
            {
                filename = Path.GetFileName(fupSkuImage.FileName);
                fupSkuImage.SaveAs(Server.MapPath("~/Sr_App/skuImages/") + filename);
            }
            else
            {
                if (hdnImageUrl.Value.ToString() != "")
                {
                    string url = hdnImageUrl.Value.ToString();
                    int    idx = url.LastIndexOf('/');
                    //Console.WriteLine(s.Substring(0, idx)); // "My. name. is Bond"
                    //Console.WriteLine(s.Substring(idx + 1)); // "_James Bond!"
                    url      = url.Substring(idx + 1);
                    filename = url;
                }
            }
            objsku.Image = filename;

            if (btnAddsku.Text == "Add")
            {
                bool res = VendorBLL.Instance.SaveSku(objsku);
                if (res)
                {
                    lblres.Text    = "Added/ Updated Successfully";
                    lblres.Visible = true;
                    ResetSku();
                    BindSku();
                }
            }
            else if (btnAddsku.Text == "Update")
            {
                objsku.Id = Convert.ToInt16(lblSkuId.Text);
                bool res = VendorBLL.Instance.UpdateSku(objsku);
                if (res)
                {
                    lblres.Text    = "Added/ Updated Successfully";
                    lblres.Visible = true;
                    ResetSku();
                    BindSku();
                }
            }
        }
 public bool UpdateSku(clsSku objsku)
 {
     return(VendorDAL.Instance.UpdateSku(objsku));
 }
 public bool SaveSku(clsSku objsku)
 {
     return(VendorDAL.Instance.SaveSku(objsku));
 }