protected void getAddintionalProdSrvList() { ArrayList prodSpecList = (ArrayList)Session[SessionFactory.UPDATE_PROD_SELECTED_PROD_SPEC_MAP]; if (prodSpecList == null) { prodSpecList = new ArrayList(); } BackEndObjects.ShopChildProdsSpecs rfqSpec = new ShopChildProdsSpecs(); //rfqSpec.set(Session[SessionFactory.CREATE_PRODUCT_SELECTED_PRODUCT_CAT].ToString()); rfqSpec.setEntityId(Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString()); rfqSpec.setFeatId("ft_dummy"); rfqSpec.setFromSpecId(""); rfqSpec.setToSpecId(""); rfqSpec.setSpecText(TextBox_Spec.Text); rfqSpec.setProdName(Session[SessionFactory.ALL_PRODUCT_SELECTED_PRODUCT_NAME].ToString()); //rfqSpec.setCreatedDate(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); //if (User.Identity.Name != null) //rfqSpec.setCreatedUsr(User.Identity.Name); if (FileUpload_Extra_Spec.HasFile) { rfqSpec.setFileStream(FileUpload_Extra_Spec); } prodSpecList.Add(rfqSpec); Session[SessionFactory.UPDATE_PROD_SELECTED_PROD_SPEC_MAP] = prodSpecList; }
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { DataTable dt = (DataTable)Session[SessionFactory.ALL_PROD_SPECIFICATION_DATAGRID]; String prodName = Session[SessionFactory.ALL_PRODUCT_SELECTED_PRODUCT_NAME].ToString(); String fromSpecText = ((DropDownList)GridView1.Rows[e.RowIndex].Cells[0].FindControl("DropDownList_From_Spec_Edit")).SelectedItem != null ? ((DropDownList)GridView1.Rows[e.RowIndex].Cells[0].FindControl("DropDownList_From_Spec_Edit")).SelectedItem.Text : ""; String fromSpecId = ((DropDownList)GridView1.Rows[e.RowIndex].Cells[0].FindControl("DropDownList_From_Spec_Edit")).SelectedValue != null ? ((DropDownList)GridView1.Rows[e.RowIndex].Cells[0].FindControl("DropDownList_From_Spec_Edit")).SelectedValue:""; String ToSpecText = ((DropDownList)GridView1.Rows[e.RowIndex].Cells[0].FindControl("DropDownList_To_Spec_Edit")).SelectedItem != null ? ((DropDownList)GridView1.Rows[e.RowIndex].Cells[0].FindControl("DropDownList_To_Spec_Edit")).SelectedItem.Text:""; String ToSpecId = ((DropDownList)GridView1.Rows[e.RowIndex].Cells[0].FindControl("DropDownList_To_Spec_Edit")).SelectedValue != null ? ((DropDownList)GridView1.Rows[e.RowIndex].Cells[0].FindControl("DropDownList_To_Spec_Edit")).SelectedValue:""; String specText = ((TextBox)GridView1.Rows[e.RowIndex].Cells[0].FindControl("TextBox_SpecText_Edit")).Text; int index = GridView1.Rows[e.RowIndex].DataItemIndex; dt.Rows[index]["SpecText"] = specText; dt.Rows[index]["FromSpec"] = fromSpecText; dt.Rows[index]["ToSpec"] = ToSpecText; String updatedImgPath = ""; Dictionary <String, String> whereCls = new Dictionary <string, string>(); Dictionary <String, String> targetVals = new Dictionary <string, string>(); whereCls.Add(BackEndObjects.ShopChildProdsSpecs.SHOP_CHILD_PROD_SPEC_COL_PROD_NAME, prodName); whereCls.Add(BackEndObjects.ShopChildProdsSpecs.SHOP_CHILD_PROD_SPEC_COL_ENTITY_ID, Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString()); whereCls.Add(BackEndObjects.ShopChildProdsSpecs.SHOP_CHILD_PROD_SPEC_COL_FEAT_ID, ((Label)GridView1.Rows[e.RowIndex].Cells[0].FindControl("Label_Hidden_Feat")).Text); if (!((FileUpload)GridView1.Rows[e.RowIndex].Cells[0].FindControl("FileUpload_Image")).HasFile) { targetVals.Add(BackEndObjects.ShopChildProdsSpecs.SHOP_CHILD_PROD_SPEC_COL_FROM_SPEC_ID, fromSpecId); targetVals.Add(BackEndObjects.ShopChildProdsSpecs.SHOP_CHILD_PROD_SPEC_COL_TO_SPEC_ID, ToSpecId); targetVals.Add(BackEndObjects.ShopChildProdsSpecs.SHOP_CHILD_PROD_SPEC_COL_SPEC_TEXT, specText); BackEndObjects.ShopChildProdsSpecs.updateShopChildProdsSpecsDB(targetVals, whereCls, DBConn.Connections.OPERATION_UPDATE); } else { //Remove the entry and re-create BackEndObjects.ShopChildProdsSpecs.updateShopChildProdsSpecsDB(targetVals, whereCls, DBConn.Connections.OPERATION_DELETE); BackEndObjects.ShopChildProdsSpecs specObj = new ShopChildProdsSpecs(); specObj.setEntityId(Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString()); specObj.setFeatId(((Label)GridView1.Rows[e.RowIndex].Cells[0].FindControl("Label_Hidden_Feat")).Text); specObj.setFileStream(((FileUpload)GridView1.Rows[e.RowIndex].Cells[0].FindControl("FileUpload_Image"))); specObj.setFromSpecId(fromSpecId); specObj.setSpecText(specText); specObj.setToSpecId(ToSpecId); specObj.setProdName(prodName); specObj.setImgPathInFileStore(Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString()); BackEndObjects.ShopChildProdsSpecs.insertShopChildProdsSpecsDB(specObj); String[] imgPath = specObj.getImgPath().Split(new String[] { "\\" }, StringSplitOptions.RemoveEmptyEntries); dt.Rows[index]["imgName"] = (imgPath != null && imgPath.Length > 0 ? imgPath[imgPath.Length - 1] : "N\\A"); updatedImgPath = specObj.getImgPath(); } Session[SessionFactory.ALL_PROD_SPECIFICATION_DATAGRID] = dt; GridView1.EditIndex = -1; GridView1.DataSource = dt; GridView1.DataBind(); }