protected void RepeaterMobileSIMPurchase_ItemCommand(object source, RepeaterCommandEventArgs e) { try { if (e.CommandName == "Delete") { if (ViewState["objDTMobile"] != null) { DataTable dt = (DataTable)ViewState["objDTMobile"]; DataRow drCurrentRow = null; int rowIndex = Convert.ToInt32(e.Item.ItemIndex); if (dt.Rows.Count > 1) { dt.Rows.Remove(dt.Rows[rowIndex]); drCurrentRow = dt.NewRow(); ViewState["objDTMobile"] = dt; RepeaterMobileSIMPurchase.DataSource = dt; RepeaterMobileSIMPurchase.DataBind(); } else if (dt.Rows.Count == 1) { dt.Rows.Remove(dt.Rows[rowIndex]); fillblankGridForMobileSIM(); } } } } catch (Exception ex) { } }
protected void UploadFile(FileUpload FuBulkDetails) { try { if (FuBulkDetails.HasFile) { if (FuBulkDetails.FileName.Contains(".csv")) { string strPath = Server.MapPath("InventoryFiles") + "/" + FuBulkDetails.FileName; if (rbMobileSIMPurchase.Checked == true) { FuBulkDetails.SaveAs(strPath); ViewState["MobileSIMPurchaseBulk"] = strPath; ViewState["objDTMobile"] = CSVTODatTable(strPath, (DataTable)ViewState["objDTMobile"]); RepeaterMobileSIMPurchase.DataSource = ViewState["objDTMobile"]; RepeaterMobileSIMPurchase.DataBind(); //if (RepeaterMobileSIMPurchase.Items.Count > 0) //{ // Grid.Visible = true; //} //else //{ // Grid.Visible = false; //} } else { FuBulkDetails.SaveAs(strPath); ViewState["SIMPurchaseBulk"] = strPath; ViewState["objDTSIM"] = CSVTODatTableSIMPurchaseBulk(strPath, (DataTable)ViewState["objDTSIM"]); RepeaterSIMPurchase.DataSource = ViewState["objDTSIM"]; RepeaterSIMPurchase.DataBind(); } } else { ScriptManager.RegisterStartupScript(this, Page.GetType(), "File Column Mismatch1", "alert('Please upload only .csv file')", true); } } else { ScriptManager.RegisterStartupScript(this, Page.GetType(), "File Column Mismatch2", "alert('Please select file for upload')", true); } } catch (Exception ex) { throw ex; } }
protected void fillblankGridForMobileSIM() { //MobileSIMPurchase if (ViewState["objDTMobile"] == null) { dtfillGridMobileSIMPurchase = new DataTable(); dtfillGridMobileSIMPurchase.Columns.Add("MobileNo"); dtfillGridMobileSIMPurchase.Columns.Add("SIMNo"); dtfillGridMobileSIMPurchase.Columns.Add("PIN"); dtfillGridMobileSIMPurchase.Columns.Add("PUK"); dtfillGridMobileSIMPurchase.Columns.Add("SIMType"); dtfillGridMobileSIMPurchase.Columns.Add("SIMTypeID"); } else { dtfillGridMobileSIMPurchase = (DataTable)ViewState["objDTMobile"]; dtfillGridMobileSIMPurchase.Rows.Clear(); } DataRow dr = dtfillGridMobileSIMPurchase.NewRow(); dr = dtfillGridMobileSIMPurchase.NewRow(); for (int i = 0; i < dtfillGridMobileSIMPurchase.Columns.Count; i++) { dr[i] = ""; } dtfillGridMobileSIMPurchase.Rows.Add(dr); dtfillGridMobileSIMPurchase.AcceptChanges(); RepeaterMobileSIMPurchase.DataSource = dtfillGridMobileSIMPurchase; RepeaterMobileSIMPurchase.DataBind(); ViewState["objDTMobile"] = dtfillGridMobileSIMPurchase; for (int i = 0; i < RepeaterMobileSIMPurchase.Items.Count; i++) { LinkButton linkbtn = (LinkButton)RepeaterMobileSIMPurchase.Items[i].FindControl("lbtnRemove"); linkbtn.Enabled = false; } }
protected void btnADDNewRowforMobileSIM_Click(object sender, EventArgs e) { try { DataTable objDt = (DataTable)ViewState["objDTMobile"]; if (objDt.Rows.Count == 1) { if (Convert.ToString(objDt.Rows[0]["MobileNo"]) == "") { objDt.Rows.RemoveAt(0); } } DataRow objDr = objDt.NewRow(); objDr["MobileNo"] = txtMobileforMobileSIM.Text.Trim(); objDr["SimNo"] = txtSIMforMobileSIM.Text.Trim(); objDr["PIN"] = txtPINforMobileSIM.Text.Trim(); objDr["PUK"] = txtPUKforMobileSIM.Text.Trim(); objDr["SIMType"] = ddlSIMTypeforMobileSIM.SelectedItem.Text; objDr["SIMTypeID"] = ddlSIMTypeforMobileSIM.SelectedValue; objDt.Rows.Add(objDr); objDt.AcceptChanges(); ViewState["objDTMobile"] = objDt; RepeaterMobileSIMPurchase.DataSource = ViewState["objDTMobile"]; RepeaterMobileSIMPurchase.DataBind(); //ClaculateNoOfRecords(); txtMobileforMobileSIM.Text = string.Empty; txtSIMforMobileSIM.Text = string.Empty; txtPINforMobileSIM.Text = String.Empty; txtPUKforMobileSIM.Text = String.Empty; } catch (Exception ex) { throw ex; } }
protected void btnADDNewRowForSIM_Click(object sender, EventArgs e) { try { RepeaterMobileSIMPurchase.Visible = true; rptErrot.Visible = false; btnReplace.Visible = true; DataTable objDt = (DataTable)ViewState["objDTMobile"]; if (objDt.Rows.Count == 1) { if (Convert.ToString(objDt.Rows[0]["SIMNo"]) == "") { objDt.Rows.RemoveAt(0); } } DataRow objDr = objDt.NewRow(); objDr["SimNo"] = txtSIMNumber.Text.Trim(); objDt.Rows.Add(objDr); objDt.AcceptChanges(); ViewState["objDTMobile"] = objDt; RepeaterMobileSIMPurchase.DataSource = ViewState["objDTMobile"]; RepeaterMobileSIMPurchase.DataBind(); //ClaculateNoOfRecords(); txtSIMNumber.Text = String.Empty; } catch (Exception ex) { throw ex; } }