private Boolean checkInvalidProject() { foreach (DataRow dr in dtProjectLIst.Rows) { if (dr["Active"].ToString() == "N") { Session["errorMessage"] = "Project Code: " + dr["ProjectCodeOnly"].ToString() + " is inactive."; ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "OKErrors", "Main.setMasterMessage('" + GeneralFunctions.UrlFullEncode(dr["ProjectCodeOnly"].ToString() + " is inactive.") + "','');", true); return(false); } } return(true); }
protected void Post_Click(object sender, EventArgs e) { try { if (checkInvalidProject()) { if (GF == null) { GF = new GeneralFunctions(HttpContext.Current.User.Identity.Name); // Added by thangnv } if (postJVForLabourAct() && postJVForBillingAct()) { ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "CloseLoading", "Dialog.hideLoader();", true); //update status. updateAllPosted(); Filter_Click(null, null); this.btnPost.Enabled = false; //cannot post again this.lbError.Text = "Operation complete sucessful!"; Session["successMessage"] = "Operation complete sucessful!"; ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "OKErrors", "Main.setMasterMessage('" + "Operation complete sucessful!" + "','');", true); } } else { ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "CloseLoading", "Dialog.hideLoader();", true); } } catch (Exception ex) { this.lbError.Text = ex.Message; Session["errorMessage"] = ex.Message; ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "OKErrors", "Main.setMasterMessage('" + GeneralFunctions.UrlFullEncode(ex.Message) + "','');", true); } }
protected bool DataValidation() { bool valid = true; string lsProject = string.Empty; List <string> ProjectList = new List <string>(); ProjectList = GetProjectList(); for (int x = 1; x < this.FileLines.Count; x++) { string[] rowData = FileLines[x].ToString().Split(','); if (!ProjectList.Contains(rowData[0])) { lsProject = (string.IsNullOrEmpty(lsProject) ? rowData[0] : lsProject + "; " + rowData[0]); valid = false; } } if (!valid) { StatusLabel.ForeColor = System.Drawing.Color.Red; StatusLabel.Font.Bold = true; string lsMsg = "Import failure. Projects invalid: " + lsProject; StatusLabel.Text = "Import failure. <br/> Projects invalid: " + lsProject;; Session["errorMessage"] = lsMsg; ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "OKErrors", "Main.setMasterMessage('" + GeneralFunctions.UrlFullEncode(lsMsg) + "','');", true); } return(valid); }
private DataTable GetprojectList() { DataSet dsPrjList = null; try { dsPrjList = SqlHelper.ExecuteDataSet(Data.ConnectionString, CommandType.StoredProcedure, "sp_ProjectList"); if (dsPrjList == null || dsPrjList.Tables == null) { return(null); } } catch (Exception ex) { Session["errorMessage"] = ex.Message; ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "OKErrors", "Main.setMasterMessage('" + GeneralFunctions.UrlFullEncode(ex.Message) + "','');", true); return(null); } return(dsPrjList.Tables[0]); }
private bool postJVForBillingAct() { DocumentXML objInfo = new DocumentXML(); DataSet dsJV; DataTable tbCompany = dtJVLineCost.DefaultView.ToTable(true, "Company");//true: distinct Array arrContentsCols = new string[] { "Debit", "Credit" }; DataTable eachCompany; eachCompany = new DataTable("BTF1"); eachCompany = dtJVLineCost.Clone(); SAP.WebServices.Transaction ts = new WebServices.Transaction(); ts.Timeout = 1000000; foreach (DataRow row in tbCompany.Rows) { String companyName = row["Company"].ToString(); dsJV = new DataSet("DS"); dsJV.Tables.Add(dtJVHeader.Copy()); DataRow[] drows; eachCompany.Rows.Clear(); drows = dtJVLineCost.Select("Company = '" + companyName + "' AND (Debit <> 0 OR Credit <> 0)"); if (drows.Length > 0) { //string newact = ""; foreach (DataRow rw in drows) { DataRow dr = eachCompany.NewRow(); dr["Company"] = rw["Company"]; string act = rw["Account"].ToString(); //newact = act.Substring(0, 5) + "-" + act.Substring(5, 2) + "-" + act.Substring(7, 2); // "_SYS00000000189";// newact; dr["Account"] = act; dr["Debit"] = rw["Debit"]; dr["Credit"] = rw["Credit"]; dr["Project"] = rw["Project"]; eachCompany.Rows.Add(dr); } //dsJV.Tables.Add(eachCompany.Copy()); dsJV.Tables.Add(GF.ResetFormatNumeric(eachCompany.Copy(), arrContentsCols)); String xmlStrJV = objInfo.ToXMLStringFromDS("28", dsJV); //2. post to SAP (JV) DataSet dsResult = ts.CreateMarketingDocument(xmlStrJV, companyName, "28", "", false);//User.Identity.Name if ((int)dsResult.Tables[0].Rows[0]["ErrCode"] != 0) { this.lbError.Text = dsResult.Tables[0].Rows[0]["ErrMsg"].ToString(); Session["errorMessage"] = dsResult.Tables[0].Rows[0]["ErrMsg"]; Session["requestXML"] = xmlStrJV; ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "OKErrors", "Main.setMasterMessage('" + GeneralFunctions.UrlFullEncode(dsResult.Tables[0].Rows[0]["ErrMsg"].ToString() + "-" + xmlStrJV) + "','');", true); return(false); } } } ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "CloseLoading", "Dialog.hideLoader();", true); return(true); }