protected void BtnSave_Click(object sender, EventArgs e) { int InsertRow = 0, InsertRowDtls = 0; try { DS = Obj_SL.ChkDuplicate(TxtStockLocation.Text.Trim(), out StrError); if (DS.Tables[0].Rows.Count > 0) { obj_Comm.ShowPopUpMsg("Location Name Already Exist..!", this.Page); TxtStockLocation.Focus(); } else { Entity_SL.Location = TxtStockLocation.Text.Trim(); Entity_SL.abbreviation = Txtabbreviations.Text.Trim(); Entity_SL.SiteId = 0; Entity_SL.TowerId = 0; Entity_SL.CompanyId = Convert.ToInt32(ddlcompany.SelectedValue); Entity_SL.SiteAddr = TxtSiteAddr.Text; Entity_SL.UserId = Convert.ToInt32(Session["UserId"]); Entity_SL.LoginDate = DateTime.Now; Entity_SL.IsDeleted = false; Entity_SL.IsCental = chkCenLoc.Checked ? true : false; InsertRow = Obj_SL.InsertRecord(ref Entity_SL, out StrError); if (InsertRow > 0) { if (ViewState["CurrentTable"] != null) { DataTable dtInsert = new DataTable(); dtInsert = (DataTable)ViewState["CurrentTable"]; for (int i = 0; i < dtInsert.Rows.Count; i++) { Entity_SL.StockLocationID = InsertRow; Entity_SL.EmployeeId = Convert.ToInt32(dtInsert.Rows[i]["EmployeeId"].ToString()); Entity_SL.CpersonName = dtInsert.Rows[i]["PersonName"].ToString(); Entity_SL.ContactNo = dtInsert.Rows[i]["ContactNo"].ToString(); Entity_SL.MailId = dtInsert.Rows[i]["EmailId"].ToString(); Entity_SL.PersonAddress = dtInsert.Rows[i]["Address"].ToString(); InsertRowDtls = Obj_SL.InsertDetailsRecord(ref Entity_SL, out StrError); } } if (InsertRow != 0) { obj_Comm.ShowPopUpMsg("Record Saved Successfully", this.Page); MakeControlEmpty(); MakeEmptyForm(); Entity_SL = null; obj_Comm = null; } } } } catch (Exception ex) { throw new Exception(ex.Message); } }
//User Right Function=========== private void MakeEmptyForm() { TxtStockLocation.Focus(); if (!FlagAdd) { BtnSave.Visible = true; } BtnUpdate.Visible = false; BtnDelete.Visible = false; TxtStockLocation.Text = string.Empty; ddlPersonName.SelectedValue = "0"; TxtSiteAddr.Text = string.Empty; Txtabbreviations.Text = string.Empty; TxtSearch.Text = string.Empty; chkCenLoc.Checked = false; SetInitialRow(); ReportGrid(StrCondition); }
protected void GrdReport_ItemCommand(object source, RepeaterCommandEventArgs e) { try { switch (e.CommandName) { case ("Select"): { if (Convert.ToInt32(e.CommandArgument) != 0) { ViewState["EditID"] = Convert.ToInt32(e.CommandArgument); DS = Obj_SL.GetStockLOcationForEdit(Convert.ToInt32(e.CommandArgument), out StrError); if (DS.Tables.Count > 0 && DS.Tables[0].Rows.Count > 0) { ddlcompany.SelectedValue = DS.Tables[0].Rows[0]["CompanyID"].ToString(); TxtStockLocation.Text = DS.Tables[0].Rows[0]["Location"].ToString(); Txtabbreviations.Text = DS.Tables[0].Rows[0]["abbreviation"].ToString(); TxtSiteAddr.Text = DS.Tables[0].Rows[0]["SiteAddr"].ToString(); if (Convert.ToBoolean(DS.Tables[0].Rows[0]["IsCentral"].ToString()) == true) { chkCenLoc.Checked = true; } else { chkCenLoc.Checked = false; } } else { MakeEmptyForm(); } if (DS.Tables[1].Rows.Count > 0) { GridDetails.DataSource = DS.Tables[1]; GridDetails.DataBind(); ViewState["CurrentTable"] = DS.Tables[1]; } else { SetInitialRow(); } DS = null; Obj_SL = null; if (!FlagEdit) { BtnUpdate.Visible = true; } BtnSave.Visible = false; if (!FladDel) { BtnDelete.Visible = true; } TxtStockLocation.Focus(); MakeControlEmpty(); } break; } } } catch (Exception ex) { throw new Exception(ex.Message); } }