private void BindStoreBankingDetail() { try { if (this.storeBankingDetailId > 0) { StoreBankingDetail storeBankingDetail = StoreBankingDetail.GetStoreBankingDetailByStoreBankingDetailId(this.storeBankingDetailId); TextBoxBranchNumber.Text = storeBankingDetail.BranchNumber.ToString(); TextBoxAccountNumber.Text = storeBankingDetail.AccountNumber.ToString(); DropDownListStoreBankAccountType.Items.FindByValue(storeBankingDetail.StoreBankAccountTypeId.ToString()).Selected = true; TextBoxEmailNotify1.Text = storeBankingDetail.EmailNotify1; TextBoxEmailAddress1.Text = storeBankingDetail.EmailAddress1; } } catch (System.Data.SqlClient.SqlException sqlEx) { for (int i = 0; i < sqlEx.Errors.Count; i++) { LabelError.Text += (sqlEx.Errors[i].Message + "<br />"); } PanelError.Visible = true; } catch (Exception exception) { LabelError.Text += (exception.Message + "<br />"); PanelError.Visible = true; } }
private void CompanyBankingReport(int companyId) { int index = 1; string sFileName = System.IO.Path.GetRandomFileName().Substring(0, 8); string sGenName = "Payment_CSV_Template.csv"; string claimMonth = DropDownListMonth.SelectedItem.Text; using (System.IO.StreamWriter SW = new System.IO.StreamWriter(Server.MapPath("Upload/" + sFileName + ".csv"))) { SW.WriteLine(String.Format("{0}", "BInSol - U ver 1.00")); SW.WriteLine(String.Format("{0}/{1}/{2}", claimMonth.Substring(5, 2), "01", claimMonth.Substring(0, 4))); SW.WriteLine(""); SW.WriteLine("RECIPIENT NAME,RECIPIENT ACCOUNT,RECIPIENT ACCOUNT TYPE,BRANCHCODE,AMOUNT,OWN REFERENCE,RECIPIENT REFERENCE,EMAIL 1 NOTIFY,EMAIL 1 ADDRESS,EMAIL 1 SUBJECT,EMAIL 2 NOTIFY,EMAIL 2 ADDRESS,EMAIL 2 SUBJECT,EMAIL 3 NOTIFY,EMAIL 3 ADDRESS,EMAIL 3 SUBJECT,EMAIL 4 NOTIFY,EMAIL 4 ADDRESS,EMAIL 4 SUBJECT,EMAIL 5 NOTIFY,EMAIL 5 ADDRESS,EMAIL 5 SUBJECT,FAX 1 NOTIFY,FAX 1 CODE,FAX 1 NUMBER,FAX 1 SUBJECT,FAX 2 NOTIFY,FAX 2 CODE,FAX 2 NUMBER,FAX 2 SUBJECT,SMS 1 NOTIFY,SMS 1 CODE,SMS 1 NUMBER,SMS 2 NOTIFY,SMS 2 CODE,SMS 2 NUMBER"); string row = ""; List <StoreBankingDetail> cs = StoreBankingDetail.GetReportClaimBankingMMS(claimMonth, companyId, Convert.ToInt32(DropDownListLocation.SelectedValue), Convert.ToInt32(DropDownListSupplier.SelectedValue), Convert.ToInt32(DropDownListClaimType.SelectedValue)); if (cs.Count > 0) { foreach (StoreBankingDetail claim in cs) { row = String.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},", claim.StoreName, claim.AccountNumber, claim.AccountType, claim.BranchNumber, claim.Amount, claim.OwnReference, claim.RecipientReference, claim.EmailNotify1, claim.EmailAddress1, claim.EmailSubject1); SW.WriteLine(row); index++; } SW.Close(); } else { LabelError.Text = "No rows returned."; PanelError.Visible = true; } } System.IO.FileStream fs = null; fs = System.IO.File.Open(Server.MapPath("Upload/" + sFileName + ".csv"), System.IO.FileMode.Open); byte[] btFile = new byte[fs.Length]; fs.Read(btFile, 0, Convert.ToInt32(fs.Length)); fs.Close(); Response.AddHeader("Content-disposition", "attachment; filename=" + sGenName); Response.ContentType = "application/octet-stream"; Response.BinaryWrite(btFile); Response.End(); }
protected void ButtonSave_Click(object sender, EventArgs e) { if (Page.IsValid) { StoreBankingDetail storeBankingDetail = new StoreBankingDetail(); storeBankingDetail.StoreBankingDetailId = this.storeBankingDetailId; storeBankingDetail.StoreId = this.storeId; storeBankingDetail.BranchNumber = TextBoxBranchNumber.Text; storeBankingDetail.AccountNumber = TextBoxAccountNumber.Text; storeBankingDetail.StoreBankAccountTypeId = Convert.ToInt32(DropDownListStoreBankAccountType.SelectedValue); storeBankingDetail.EmailNotify1 = (TextBoxEmailNotify1.Text.Length > 0) ? TextBoxEmailNotify1.Text : ""; storeBankingDetail.EmailAddress1 = (TextBoxEmailAddress1.Text.Length > 0) ? TextBoxEmailAddress1.Text : ""; storeBankingDetail.ModifiedUser = this.Master.LoggedOnAccount; storeBankingDetail.CompanyId = Account.GetAccountByUserName(Page.User.Identity.Name.ToString()).CompanyId; try { storeBankingDetail.Save(); int storeBankingDetailId = storeBankingDetail.StoreBankingDetailId; Button clickedButton = (Button)sender; switch (clickedButton.ID) { case "ButtonSaveList": Response.Redirect("StoreList.aspx"); break; } } catch (System.Data.SqlClient.SqlException sqlEx) { LabelError.Text = ""; for (int i = 0; i < sqlEx.Errors.Count; i++) { LabelError.Text += (sqlEx.Errors[i].Message + "<br />"); } PanelError.Visible = true; } } }
protected void ButtonDelete_Click(object sender, EventArgs e) { if (Page.IsValid) { try { StoreBankingDetail.DeleteStoreBankingDetailByStoreBankingDetailId(this.storeBankingDetailId); string message = String.Format("StoreBankingDetail deleted - StoreBankingDetailId:{0}, StoreId:{1}, BranchNumber:{2}, AccountNumber:{3},EmailNotify:{4}, EmailAddress:{5}, DeletedBy:{6}", this.storeBankingDetailId, this.storeId, TextBoxBranchNumber.Text, TextBoxAccountNumber.Text, TextBoxEmailNotify1.Text, TextBoxEmailAddress1.Text, this.Master.LoggedOnAccount); Utility.WriteLog(1000, 5, message, "Activity", TraceEventType.Information, "StoreBankingDetail"); Response.Redirect("StoreList.aspx"); } catch (System.Data.SqlClient.SqlException sqlEx) { LabelError.Text = ""; for (int i = 0; i < sqlEx.Errors.Count; i++) { LabelError.Text += (sqlEx.Errors[i].Message + "<br />"); } PanelError.Visible = true; } } }