protected void RepeaterSIMPurchase_ItemCommand(object source, RepeaterCommandEventArgs e) { try { if (e.CommandName == "Delete") { if (ViewState["objDTMobile"] != null) { DataTable dt = (DataTable)ViewState["objDTSIM"]; 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["objDTSIM"] = dt; RepeaterSIMPurchase.DataSource = dt; RepeaterSIMPurchase.DataBind(); } else if (dt.Rows.Count == 1) { dt.Rows.Remove(dt.Rows[rowIndex]); fillblankGridForSIM(); } } } } 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 btnADDNewRowForSIM_Click(object sender, EventArgs e) { try { DataTable objDt = (DataTable)ViewState["objDTSIM"]; if (objDt.Rows.Count == 1) { if (Convert.ToString(objDt.Rows[0]["SIMNo"]) == "") { objDt.Rows.RemoveAt(0); } } DataRow objDr = objDt.NewRow(); objDr["SimNo"] = txtSIM.Text.Trim(); objDr["PIN"] = txtPIN.Text.Trim(); objDr["PUK"] = txtPUK.Text.Trim(); objDr["SIMType"] = "Normal SIM"; //ddlSIMTypeForSIM.SelectedItem.Text; objDr["SIMTypeID"] = 12; //ddlSIMTypeForSIM.SelectedValue; objDt.Rows.Add(objDr); objDt.AcceptChanges(); ViewState["objDTSIM"] = objDt; RepeaterSIMPurchase.DataSource = ViewState["objDTSIM"]; RepeaterSIMPurchase.DataBind(); //ClaculateNoOfRecords(); if (ddlVendor.SelectedValue == "13") { txtSIM.Text = "8919601"; } else { txtSIM.Text = ""; } txtPIN.Text = "0000"; txtPUK.Text = "0000000"; //txtPIN.Enabled = false; //txtPUK.Enabled = false; ddlSIMTypeForSIM.SelectedIndex = 1; //ddlSIMTypeForSIM.Attributes.Add("disabled", "true"); } catch (Exception ex) { throw ex; } }
protected void fillblankGridForSIM() { //SIMPurchase if (ViewState["objDTSIM"] == null) { dtfillGridSIMPurchase = new DataTable(); dtfillGridSIMPurchase.Columns.Add("SIMNo"); dtfillGridSIMPurchase.Columns.Add("PIN"); dtfillGridSIMPurchase.Columns.Add("PUK"); dtfillGridSIMPurchase.Columns.Add("SIMType"); dtfillGridSIMPurchase.Columns.Add("SIMTypeID"); } else { dtfillGridSIMPurchase = (DataTable)ViewState["objDTSIM"]; dtfillGridSIMPurchase.Rows.Clear(); } DataRow drSIM = dtfillGridSIMPurchase.NewRow(); drSIM = dtfillGridSIMPurchase.NewRow(); for (int i = 0; i < dtfillGridSIMPurchase.Columns.Count; i++) { drSIM[i] = ""; } dtfillGridSIMPurchase.Rows.Add(drSIM); dtfillGridSIMPurchase.AcceptChanges(); RepeaterSIMPurchase.DataSource = dtfillGridSIMPurchase; RepeaterSIMPurchase.DataBind(); ViewState["objDTSIM"] = dtfillGridSIMPurchase; for (int i = 0; i < RepeaterSIMPurchase.Items.Count; i++) { LinkButton linkbtn = (LinkButton)RepeaterSIMPurchase.Items[i].FindControl("lbtnRemove"); linkbtn.Enabled = false; } }