internal int DeleteDamage_Temp(int id) { try { Inv_Damage_Temp buyCentralObj = _context.Inv_Damage_Temp.First(x => x.Id == id); _context.Inv_Damage_Temp.DeleteObject(buyCentralObj); _context.SaveChanges(); return(1); } catch (Exception) { throw; } }
protected void BtnSave_Click(object sender, EventArgs e) { try { List <Inv_Damage_Temp> _Inv_Damage_Temp = new List <Inv_Damage_Temp>(); //bool status = true; bool CheckStatus = false; foreach (GridViewRow gvRow in GridShow.Rows) { CheckBox rowChkBox = ((CheckBox)gvRow.FindControl("rowLevelCheckBox")); if (rowChkBox.Checked == true) { CheckStatus = true; } } if (CheckStatus) { foreach (GridViewRow gvr in GridShow.Rows) { CheckBox rowChkBox = ((CheckBox)gvr.FindControl("rowLevelCheckBox")); if (rowChkBox.Checked == true) { Inv_Damage_Temp returnTemp = new Inv_Damage_Temp(); Label lblproductName = (Label)gvr.FindControl("lblproductName"); Label lblBrand = (Label)gvr.FindControl("lblBrand"); Label lblStyleAndSize = (Label)gvr.FindControl("lblStyleAndSize"); Label lblSupplierReturnQty = (Label)gvr.FindControl("lblSupplierReturnQty"); Label lblCompanyId = (Label)gvr.FindControl("lblCompanyId"); Label lblCompanyName = (Label)gvr.FindControl("lblCompanyName"); Label lblproductGroup = (Label)gvr.FindControl("lblproductGroup"); Label lblReceiveQuantity = (Label)gvr.FindControl("lblReceiveQuantity"); Label lblCPU = (Label)gvr.FindControl("lblCPU"); Label lblDeliveryQty = (Label)gvr.FindControl("lblDeliveryQty"); Label lblOcode = (Label)gvr.FindControl("lblOcode"); Label lblCompanyCode = (Label)gvr.FindControl("lblCompanyCode"); Label lblPurchaseDate = (Label)gvr.FindControl("lblPurchaseDate"); Label lblBalanceQty = (Label)gvr.FindControl("lblBalanceQty"); Label lblChallanNo = (Label)gvr.FindControl("lblChallanNo"); DropDownList ddlDamageCategory = (DropDownList)gvr.FindControl("ddlDamageCategory"); Label lblBarCode = (Label)gvr.FindControl("lblBarCode"); Label lblUnitName = (Label)gvr.FindControl("lblUnitName"); TextBox txtReturnQty = (TextBox)gvr.FindControl("txtReturnQty"); TextBox txtRemarks = (TextBox)gvr.FindControl("txtRemarks"); if (txtRemarks.Text == "") { returnTemp.Remarks = "N/A"; } else { returnTemp.Remarks = txtRemarks.Text; } int ReturnQty = int.Parse(txtReturnQty.Text); returnTemp.ChallanNo = txtChalanNo.Text; returnTemp.Challan_No_To = lblChallanNo.Text; if (lblBalanceQty.Text == "") { returnTemp.BalanceQuanity = 0; } else { returnTemp.BalanceQuanity = Convert.ToInt32(lblBalanceQty.Text); } returnTemp.BarCode = lblBarCode.Text; returnTemp.Brand = lblBrand.Text; if (lblCPU.Text == "") { returnTemp.CPU = 0; } else { returnTemp.CPU = Convert.ToDecimal(lblCPU.Text); } returnTemp.CompanyCode = lblCompanyCode.Text; if (lblDeliveryQty.Text == "") { returnTemp.DeliveryQty = 0; } else { returnTemp.DeliveryQty = Convert.ToDouble(lblDeliveryQty.Text); } returnTemp.EditDate = DateTime.Today; Guid user = (((SessionUser)Session["SessionUser"]).UserId); returnTemp.EditUser = user; returnTemp.OCode = "8989"; returnTemp.CompanyCode = CentralCode.ToString(); returnTemp.ProductGroup = lblproductGroup.Text; returnTemp.ProductId = Convert.ToInt32(lblBarCode.Text); returnTemp.ProductName = lblproductName.Text; returnTemp.PurchaseDate = Convert.ToDateTime(lblPurchaseDate.Text); if (lblReceiveQuantity.Text == "") { returnTemp.ReceiveQuantity = 0; } else { returnTemp.ReceiveQuantity = Convert.ToDouble(lblReceiveQuantity.Text); } returnTemp.Store_Code = ddlStore.SelectedValue.ToString(); returnTemp.StyleSize = lblStyleAndSize.Text; returnTemp.DamageQty = ReturnQty; returnTemp.UnitName = lblUnitName.Text; returnTemp.DamageCategory = ddlDamageCategory.SelectedItem.Text; _context.Inv_Damage_Temp.AddObject(returnTemp); } } _context.SaveChanges(); ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Damage Process Temporary successfully')", true); GridShow.DataSource = null; GridShow.DataBind(); List <productsDetails> details = _BuyCentral.GetAllProduct_DamageTemp_ChallanNo(txtChalanNo.Text).ToList(); if (details.Count > 0) { grdDamage.DataSource = details; grdDamage.DataBind(); } else { grdDamage.DataSource = null; grdDamage.DataBind(); } } else { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('No Item Selected!')", true); } } catch (Exception ex) { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('" + ex.Message + "')", true); } //string BarCode = hdnBarCode.Value.ToString(); //if (BarCode == string.Empty || ddlStore.SelectedValue == "0" || txtDamageQty.Text == string.Empty) //{ // return; //} //try //{ // //DateTime date = DateTime.Today; // //try // //{ // // date = DateTime.Parse(txtDate.Text); // //} // //catch { } // Hashtable ht = new Hashtable(); // ht.Add("ChallanNo", txtChalanNo.Text); // ht.Add("BarCode", BarCode); // ht.Add("Store_Code", ddlStore.SelectedValue.ToString()); // ht.Add("DamageDate", txtDate.Text); // ht.Add("DamageQty", txtDamageQty.Text); // ht.Add("CompanyCode", CentralCode.ToString()); // DataTable dt = damage.DamageStoreWise(ht); // //if () // //{ // //lblMessage.Text = "<font color='green'>Product damage information inserted successfully!</font>"; // ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Product damage information inserted successfully!')", true); // grdDamage.DataSource = dt; // grdDamage.DataBind(); // ClearForm(); // //} // //else // //{ // // lblMessage.Text = "<font color='red'>Error in inserting product damage information!</font>"; // //} //} //catch { } }