private void btnSave_Click(object sender, EventArgs e) { string createdby = txtUser.Text.Trim(); string created = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); string department = txtDepartment.Text.Trim(); string key = txtKey.Text.Trim(); string remarks = txtRemarks.Text.Trim(); string sectHead = UserUtil.GetSectionHead(UserUtil.GetSect(GlobalService.User)); string divHead = UserUtil.GetDivisionHead(UserUtil.GetDivision(GlobalService.User)); string adm1st = "Sammy Chow Chi To (周志滔)"; string adm2nd = "Sammy Chow Chi To (周志滔)"; string query = string.Format("insert into TB_ADM_FORM_KEY (ak_createdby, ak_created, ak_department, ak_key, ak_remarks, ak_sect, ak_div, ak_adm1st, ak_adm2nd)" + " values (N'{0}', '{1}', N'{2}', N'{3}', N'{4}', N'{5}', N'{6}', N'{7}', N'{8}')", createdby, created, department, key, remarks, sectHead, divHead, adm1st, adm2nd); DataServiceCM.GetInstance().ExecuteNonQuery(query); string from = AdUtil.GetEmailByUserId(AdUtil.GetUserIdByUsername(GlobalService.User, "kmhk.local"), "kmhk.local"); string to = AdUtil.GetEmailByUserId(AdUtil.GetUserIdByUsername(sectHead, "kmhk.local"), "kmhk.local"); string text = "Application Approval required. Please click <a href=\"\\\\kdthk-dm1\\project\\it system\\MyCloud Beta\\KDTHK-DM-SP.application\">HERE</a> to approval process."; string body = "<p><span style=\"font-family: Calibri;\">" + text + "</span></p>"; EformUtil.SendApprovalEmail("", GlobalService.User, from, to, body, "Approval Required - 複製鎖匙依賴"); MessageBox.Show("Record has been saved."); DialogResult = DialogResult.OK; }
private void LoadMCData(DataTable table) { string q1 = string.Format("select d_type, d_reason, d_created, d_docno, d_custcurr, d_dntotal1, d_dntotal2, d_custname, d_custcode from TB_CM_DEBIT where d_createdby = N'{0}' and d_status != N'已發送'", GlobalService.User); using (IDataReader reader = DataServiceCM.GetInstance().ExecuteReader(q1)) { while (reader.Read()) { string type = reader.GetString(0).Trim(); string reason = reader.GetString(1).Trim(); string created = reader.GetString(2).Trim(); string docno = reader.GetString(3).Trim(); string curr = reader.GetString(4).Trim(); string total1 = reader.GetString(5).Trim(); string total2 = reader.GetString(6).Trim(); string name = reader.GetString(7).Trim(); string code = reader.GetString(8).Trim(); string title = reason + " (" + curr + ""; string total = total1 != "" ? total1 : total2; title = title + total + " )"; table.Rows.Add("已輸入", type, title, name + "(" + code + ")", created, "-", docno); } } }
private void btnReject_Click(object sender, EventArgs e) { string query = string.Format("update TB_CM_DEBIT set d_status = N'拒絕承認' where d_docno = '{0}'", _docno); DataServiceCM.GetInstance().ExecuteNonQuery(query); string sect = ""; string div = ""; string dept = ""; string createdby = ""; string text = string.Format("select d_sect, d_div, d_dept, d_createdby from TB_CM_DEBIT where d_docno = '{0}'", _docno); using (IDataReader reader = DataServiceCM.GetInstance().ExecuteReader(text)) { while (reader.Read()) { sect = reader.GetString(0).Trim(); div = reader.GetString(1).Trim(); dept = reader.GetString(2).Trim(); createdby = reader.GetString(3).Trim(); } } string subject = "Debit/Credit Note Application has been Rejected"; string content = "Dear Sir/Madam,\n\nYour Debit/Credit Note Application has been Rejected. Please go to MyCloud to revise or apply a new application.\n\nThis is system message, please do not reply."; EformUtil.SendRejectEmail(_docno, GlobalService.User, AdUtil.GetEmailByUsername(GlobalService.User, "kmhk.local"), AdUtil.GetEmailByUsername(createdby, "kmhk.local"), subject, content);//cc? }
private void LoadData(string invoice) { string query = string.Format("select o_id, o_invoice, o_vendor, o_vendorname, o_inputdate, o_paymentdate, o_currency, o_amount, o_status from TB_ACC_OUTSTANDING where o_invoice = '{0}'", invoice); int id = 0; using (IDataReader reader = DataServiceCM.GetInstance().ExecuteReader(query)) { while (reader.Read()) { id = reader.GetInt32(0); txtInvoice.Text = reader.GetString(1).Trim(); txtVendorCode.Text = reader.GetString(2).Trim(); txtVendorName.Text = reader.GetString(3).Trim(); txtInputDate.Text = reader.GetString(4).Trim(); txtPayDate.Text = reader.GetString(5).Trim(); txtCurrency.Text = reader.GetString(6).Trim(); txtAmount.Text = reader.GetString(7).Trim(); _status = reader.GetString(8).Trim(); _invoice = reader.GetString(1).Trim(); } } string text = string.Format("select od_accountcode as acc, od_accountname as accname, od_costcentre as cc, od_costcentrename as ccname, od_amount as amount" + ", od_desc1 as desc1, od_desc2 as desc2, od_desc3 as desc3, od_desc4 as desc4, od_desc5 as desc5, od_display as descdisplay from TB_ACC_OUTSTANDING_DETAIL" + " where od_o_id = '{0}'", id); DataTable table = new DataTable(); SqlDataAdapter sda = new SqlDataAdapter(text, DataServiceCM.GetInstance().Connection); sda.Fill(table); dgvOutstanding.DataSource = table; }
private void btnApprove_Click(object sender, EventArgs e) { string now = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); string text = _status == "科責承認中" ? string.Format("update TB_ACC_OUTSTANDING set o_divapproval = 'Yes', o_divapprovaldate = '{0}', o_status = N'會計處理中' where o_invoice = '{1}'", now, _invoice) : _status == "會計處理中" ? string.Format("update TB_ACC_OUTSTANDING set o_staffapproval = 'Yes', o_staffapprovaldate = '{0}', o_status = N'會計承認中' where o_invoice = '{1}'", now, _invoice) : string.Format("update TB_ACC_OUTSTANDING set o_accapproval = 'Yes', o_accapprovaldate = '{0}', o_status = N'申請處理完成' where o_invoice = '{1}'", now, _invoice); DataServiceCM.GetInstance().ExecuteNonQuery(text); string applicant = AccUtil.GetApplicant(_invoice); string div = AccUtil.GetDivisionApprover(_invoice); string staff = AccUtil.GetAccStaff(_invoice); string acc = AccUtil.GetAccApprover(_invoice); if (_status == "科責承認中") { EformUtil.SendApprovalEmail(_invoice, applicant, AdUtil.GetEmailByUsername(applicant, "kmhk.local"), AdUtil.GetEmailByUsername(staff, "kmhk.local"), "", "Outstanding Slip - " + _invoice); } if (_status == "會計處理中") { EformUtil.SendApprovalEmail(_invoice, applicant, AdUtil.GetEmailByUsername(applicant, "kmhk.local"), AdUtil.GetEmailByUsername(acc, "kmhk.local"), "", "Outstanding Slip - " + _invoice); } if (_status == "會計承認中") { EformUtil.SendFinishedEmail(_invoice, acc, AdUtil.GetEmailByUsername(acc, "kmhk.local"), AdUtil.GetEmailByUsername(applicant, "kmhk.local"), "Outstanding Slip Application Finished - " + _invoice, "You Outstanding Slip Application has been finished."); } DialogResult = DialogResult.OK; }
public OutstandingPreviewDetailForm(string invoice, string code, string name, string currency, string total, List <Outstanding> list) { InitializeComponent(); DataTable table = new DataTable(); string[] headers = { "code", "name", "ac", "acname", "cc", "ccname", "amt", "rm1", "rm2", "rm3", "rm4", "rm5" }; foreach (string header in headers) { table.Columns.Add(header); } this.Text = "Invoice: " + invoice + " Total: " + currency + " " + total; var dataList = from x in list where x.Invoice == invoice && x.VendorCode == code select new { x.AccountCode, x.CostCentre, x.Amount, x.Desc1, x.Desc2, x.Desc3, x.Desc4, x.Desc5 }; foreach (var item in dataList) { string acText = string.Format("select a_name from TB_CM_MASTER_ACCOUNTCODE where a_code = '{0}'", item.AccountCode); string acName = DataServiceCM.GetInstance().ExecuteScalar(acText).ToString(); string ccText = string.Format("select c_name from TB_CM_MASTER_COSTCENTRE where c_code = '{0}'", item.CostCentre); string ccName = DataServiceCM.GetInstance().ExecuteScalar(ccText).ToString(); table.Rows.Add(code, name, item.AccountCode, acName, item.CostCentre, ccName, item.Amount, item.Desc1, item.Desc2, item.Desc3, item.Desc4, item.Desc5); } dgvPreview.DataSource = table; }
private void deleteToolStripMenuItem_Click(object sender, EventArgs e) { switch (MessageBox.Show("Are you sure to delete selected items?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { case DialogResult.Yes: foreach (DataGridViewRow row in dgvForm.SelectedRows) { string refno = row.Cells[6].Value.ToString().Trim(); string text = string.Format("select o_id from TB_ACC_OUTSTANDING where o_invoice = '{0}'", refno); int id = (int)DataServiceCM.GetInstance().ExecuteScalar(text); string delText = string.Format("delete from TB_ACC_OUTSTANDING where o_id = '{0}'", id); string delText2 = string.Format("delete from TB_ACC_OUTSTANDING_DETAIL where od_o_id = '{0}'", id); DataServiceCM.GetInstance().ExecuteNonQuery(delText); DataServiceCM.GetInstance().ExecuteNonQuery(delText2); } MessageBox.Show("Record has been deleted"); LoadData(); break; case DialogResult.No: break; } }
public static int GetApprovalCount() { string q1 = string.Format("select count(*) from TB_FORM_PERMISSION where p_approver = N'{0}' and p_status = N'{1}'", GlobalService.User, "上司承認中"); int permission = (int)DataService.GetInstance().ExecuteScalar(q1); string q2 = string.Format("select count(*) from TB_FORM_LOANING where l_approver = N'{0}' and l_status = N'{1}'", GlobalService.User, "上司承認中"); int loaning = (int)DataService.GetInstance().ExecuteScalar(q2); string q3 = string.Format("select count(*) from TB_FORM_DEVELOP where d_approver = N'{0}' and d_status = N'{1}'", GlobalService.User, "上司承認中"); int develop = (int)DataService.GetInstance().ExecuteScalar(q3); string query = string.Format("select count(*) from TB_FORM where f_approver = N'{0}' and f_status = N'{1}'", GlobalService.User, "上司承認中"); int form = (int)DataService.GetInstance().ExecuteScalar(query); string q4 = string.Format("select count(*) from TB_FORM_R3 where (r_approver = N'{0}' and r_status = N'{1}') or (r_cmapprover = N'{0}' and r_status = N'{2}')", GlobalService.User, "上司承認中", "經管承認中"); int r3 = (int)DataService.GetInstance().ExecuteScalar(q4); string q5 = string.Format("select count(*) from TB_CM_DEBIT where (d_sect = N'{0}' and d_status = N'係責承認中') or (d_div = N'{0}' and d_status = N'科責承認中')" + " or (d_dept = N'{0}' and d_status = N'部責承認中') or (d_mcreviewer = N'{0}' and d_status = N'經管檢查中') or (d_mcfinal = N'{0}' and d_status = N'經管承認中')", GlobalService.User); int debit = (int)DataServiceCM.GetInstance().ExecuteScalar(q5); string q6 = string.Format("select count(*) from TB_CM_DEBIT_CANCEL where (c_applicant = N'{0}' or c_sect = N'{0}' or c_div = N'{0}' or c_dept = N'{0}' or c_targetsect = N'{0}' or c_targetdept = N'{0}')", GlobalService.User); int cancel = (int)DataServiceCM.GetInstance().ExecuteScalar(q6); string q7 = string.Format("select count(*) from TB_ACC_OUTSTANDING where (o_sect = N'{0}' and o_status = N'係責承認中') or (o_div = N'{0}' and o_status = N'科責承認中') or (o_dept = N'{0}' and o_status = N'部責承認中') or (o_staff = N'{0}' and o_status = N'會計處理中')" + " or (o_acc = N'{0}' and o_status = N'會計承認中')", GlobalService.User); int outstanding = (int)DataServiceCM.GetInstance().ExecuteScalar(q7); return(permission + loaning + develop + form + r3 + debit + cancel + outstanding); }
private void LoadAdmData(DataTable table) { try { string keyText = string.Format("select ak_status, ak_key, ak_remarks, ak_created, ak_id, case ak_status when N'係責承認中' then ak_sect when N'科責承認中' then ak_div when N'行政係責承認中' then ak_adm1st when N'行政科責承認中' then ak_adm2nd else '-' end from TB_ADM_FORM_KEY" + " where ak_createdby = N'{0}' and ak_status != N'申請處理完成'", GlobalService.User); using (IDataReader reader = DataServiceCM.GetInstance().ExecuteReader(keyText)) { while (reader.Read()) { table.Rows.Add(reader.GetString(0).Trim(), "複製鎖匙申請", reader.GetString(1).Trim(), reader.GetString(2).Trim(), reader.GetString(3).Trim(), reader.GetString(5).Trim(), reader.GetInt32(4)); } } string liftText = string.Format("select al_status, al_date, al_vendor, al_reason, al_created, al_id, case al_status when N'係責承認中' then al_sect when N'科責承認中' then al_div when N'行政係責承認中' then al_adm1st when N'行政科責承認中' then al_adm2nd else '-' end from TB_ADM_FORM_LIFT" + " where al_createdby = N'{0}' and al_status != N'申請處理完成'", GlobalService.User); using (IDataReader reader = DataServiceCM.GetInstance().ExecuteReader(liftText)) { while (reader.Read()) { table.Rows.Add(reader.GetString(0).Trim(), "使用載貨升降機", reader.GetString(1).Trim() + " " + reader.GetString(2).Trim(), reader.GetString(3).Trim(), reader.GetString(4).Trim(), reader.GetString(6).Trim(), reader.GetInt32(5)); } } string parkText = string.Format("select ap_status, ap_company, ap_license, ap_date, ap_created, ap_id, case ap_status when N'係責承認中' then ap_sect when N'科責承認中' then ap_div when N'行政係責承認中' then ap_adm1st when N'行政科責承認中' then ap_adm2nd else '-' end from TB_ADM_FORM_PARK" + " where ap_createdby = N'{0}' and ap_status != N'申請處理完成'", GlobalService.User); using (IDataReader reader = DataServiceCM.GetInstance().ExecuteReader(parkText)) { while (reader.Read()) { table.Rows.Add(reader.GetString(0).Trim(), "訪客車位申請", reader.GetString(1).Trim() + " " + reader.GetString(2).Trim(), reader.GetString(3).Trim(), reader.GetString(4).Trim(), reader.GetString(6).Trim(), reader.GetInt32(5)); } } string stampText = string.Format("select as_status, as_total, as_created, as_id, case as_status when N'係責承認中' then as_sect when N'科責承認中' then as_div when N'行政係責承認中' then as_adm1st when N'行政科責承認中' then as_adm2nd else '-' end from TB_ADM_FORM_STAMP" + " where as_createdby = N'{0}' and as_status != N'申請處理完成'", GlobalService.User); using (IDataReader reader = DataServiceCM.GetInstance().ExecuteReader(stampText)) { while (reader.Read()) { table.Rows.Add(reader.GetString(0).Trim(), "購買郵票", "$" + reader.GetString(1).Trim(), "-", reader.GetString(2).Trim(), reader.GetString(4).Trim(), reader.GetInt32(3)); } } string visaText = string.Format("select av_status, av_reason, av_created, av_id, case av_status when N'係責承認中' then av_sect when N'科責承認中' then av_div when N'行政係責承認中' then av_adm1st when N'行政科責承認中' then av_adm2nd else '-' end from TB_ADM_FORM_VISA" + " where av_createdby = N'{0}' and av_status != N'申請處理完成'", GlobalService.User); using (IDataReader reader = DataServiceCM.GetInstance().ExecuteReader(visaText)) { while (reader.Read()) { table.Rows.Add(reader.GetString(0).Trim(), "簽証申請", reader.GetString(1).Trim(), "-", reader.GetString(2).Trim(), reader.GetString(4).Trim(), reader.GetInt32(3)); } } } catch (Exception ex) { Debug.WriteLine(ex.Message + ex.StackTrace); } }
private void SignalChanged(string docno) { string query = string.Format("select d_status from TB_CM_DEBIT where d_docno = '{0}'", docno); string status = DataServiceCM.GetInstance().ExecuteScalar(query).ToString().Trim(); _status = status; pb1st.BackgroundImage = Properties.Resources.circle; if (status == "係責承認中") { pb2nd.BackgroundImage = Properties.Resources.circle_orange; } if (status == "科責承認中") { pb2nd.BackgroundImage = Properties.Resources.circle; pb3rd.BackgroundImage = Properties.Resources.circle_orange; pb4th.BackgroundImage = Properties.Resources.circle_gray; } if (status == "部責承認中") { pb2nd.BackgroundImage = Properties.Resources.circle; pb3rd.BackgroundImage = Properties.Resources.circle; pb4th.BackgroundImage = Properties.Resources.circle_orange; pb5th.BackgroundImage = Properties.Resources.circle_gray; } if (status == "經管確認中") { pb2nd.BackgroundImage = Properties.Resources.circle; pb3rd.BackgroundImage = Properties.Resources.circle; pb4th.BackgroundImage = Properties.Resources.circle; pb5th.BackgroundImage = Properties.Resources.circle_orange; pb6th.BackgroundImage = Properties.Resources.circle_gray; } if (status == "經管檢查中") { pb2nd.BackgroundImage = Properties.Resources.circle; pb3rd.BackgroundImage = Properties.Resources.circle; pb4th.BackgroundImage = Properties.Resources.circle; pb5th.BackgroundImage = Properties.Resources.circle; pb6th.BackgroundImage = Properties.Resources.circle_orange; pb7th.BackgroundImage = Properties.Resources.circle_gray; } if (status == "經管承認中") { pb2nd.BackgroundImage = Properties.Resources.circle; pb3rd.BackgroundImage = Properties.Resources.circle; pb4th.BackgroundImage = Properties.Resources.circle; pb5th.BackgroundImage = Properties.Resources.circle; pb6th.BackgroundImage = Properties.Resources.circle; pb7th.BackgroundImage = Properties.Resources.circle_orange; } }
private void btnOK_Click(object sender, EventArgs e) { string query = string.Format("update TB_CM_DEBIT set d_reject = N'{0}' where d_docno = '{1}'", txtReason.Text.Trim(), _docno); DataServiceCM.GetInstance().ExecuteNonQuery(query); DialogResult = DialogResult.OK; }
private void btnRecall_Click(object sender, EventArgs e) { string query = string.Format("update TB_CM_DEBIT set d_status = N'申請中', d_sectapproval = '-', d_divapproval = '-', d_deptapproval = '-' where d_docno = '{0}'", _docno); DataServiceCM.GetInstance().ExecuteNonQuery(query); DialogResult = DialogResult.OK; }
private void printToolStripMenuItem_Click(object sender, EventArgs e) { string refno = dgvFormHistory.SelectedRows[0].Cells[7].Value.ToString().Trim(); string query = string.Format("select d_directory from TB_CM_DEBIT where d_docno = '{0}'", refno); string file = DataServiceCM.GetInstance().ExecuteScalar(query).ToString().Trim(); Process.Start(file); }
private void LoadData(string noteNo) { string query = string.Format("select d_reqdate, d_reqoffice, d_reqcostcentre, d_custcode, d_custname, d_custcurr, d_payterm, d_duedate, d_custdiv" + ", d_divname, d_incharge, d_reason, d_invno, d_ringino, d_exmonth, d_exrate, d_dntotal1, d_dncurr, d_dntotal2, d_pdf, d_deduct, d_mention" + ", d_createdby, d_created, d_sect, d_sectapproval, d_sectdate, d_div, d_divapproval, d_divdate, d_dept, d_deptapproval, d_deptdate from TB_CM_DEBIT where d_docno = '{0}'", noteNo); using (IDataReader reader = DataServiceCM.GetInstance().ExecuteReader(query)) { while (reader.Read()) { txtReqDate.Text = reader.GetString(0).Trim(); txtReqOffice.Text = reader.GetString(1).Trim(); txtReqCostcentre.Text = reader.GetString(2).Trim(); txtCustCode.Text = reader.GetString(3).Trim(); txtCustName.Text = reader.GetString(4).Trim(); txtCustCurr.Text = reader.GetString(5).Trim(); txtPayTerm.Text = reader.GetString(6).Trim(); txtDueDate.Text = reader.GetString(7).Trim(); txtCustDiv.Text = reader.GetString(8).Trim(); txtDivName.Text = reader.GetString(9).Trim(); txtIncharge.Text = reader.GetString(10).Trim(); txtReason.Text = reader.GetString(11).Trim(); txtInvNo.Text = reader.GetString(12).Trim(); txtRingiNo.Text = reader.GetString(13).Trim(); txtExMonth.Text = reader.GetString(14).Trim(); txtExRate.Text = reader.GetString(15).Trim(); txtDnTotal1.Text = reader.GetString(16).Trim(); txtDnCurr2.Text = reader.GetString(17).Trim(); txtDnTotal2.Text = reader.GetString(18).Trim(); string pdf = reader.GetString(19).Trim(); string deduct = reader.GetString(20).Trim(); txtMention.Text = reader.GetString(21).Trim(); string createdby = reader.GetString(22).Trim(); string created = reader.GetString(23).Trim(); lblRequester.Text = "Form was created by " + createdby + " at " + created; string sect = reader.GetString(24).Trim(); string sectapp = reader.GetString(25).Trim(); string sectdate = reader.GetString(26).Trim(); lblSection.Text = "Form was approved by " + sect + " at " + sectdate; string div = reader.GetString(27).Trim(); string divapp = reader.GetString(28).Trim(); string divdate = reader.GetString(29).Trim(); lblDivision.Text = "Form was approved by " + div + " at " + divdate; } } }
private void LoadData(string source) { DataTable table = new DataTable(); string query = string.Format("select cu_month as mon, cu_type as item, cu_description as description, cu_currency as rate from TB_CM_MASTER_CURRENCY where cu_month like '%{0}%'", source); SqlDataAdapter sda = new SqlDataAdapter(query, DataServiceCM.GetInstance().Connection); sda.Fill(table); dgvCurrency.DataSource = table; }
private Boolean IsAllItemApprovedByAcc(int id) { string query = string.Format("select * from TB_ACC_OUTSTANDING_DETAIL where od_o_id = '{0}' and od_divapproval = 'No'", id); using (SqlDataReader reader = DataServiceCM.GetInstance().ExecuteReader(query)) { if (reader.HasRows) { return(false); } } return(true); }
private void LoadData(string source) { DataTable table = new DataTable(); string query = string.Format("select cust_code as code, cust_name as name, cust_curr as curr, cust_payterm as payterm, cust_currtype as currtype, cust_currdesc as currdesc" + " from TB_CM_MASTER_CUSTOMER where cust_name like N'%{0}%' or cust_shortname like '%{0}%' order by cust_vc, cust_type, cust_name", source); SqlDataAdapter sda = new SqlDataAdapter(query, DataServiceCM.GetInstance().Connection); sda.Fill(table); dgvCustomer.DataSource = table; }
private void LoadData(string source, string type) { DataTable table = new DataTable(); string query = type == "code" ? string.Format("select v_code as vendor, v_name as vendorname, v_payterm as payterm, v_currency as curr from TB_ACC_MASTER_VENDOR where v_code like '%{0}%'", source) : string.Format("select v_code as vendor, v_name as vendorname, v_payterm as payterm, v_currency as curr from TB_ACC_MASTER_VENDOR where v_name like N'%{0}%'", source); SqlDataAdapter sda = new SqlDataAdapter(query, DataServiceCM.GetInstance().Connection); sda.Fill(table); dgvVendor.DataSource = table; }
private void sendToolStripMenuItem_Click(object sender, EventArgs e) { foreach (DataGridViewRow row in dgvForm.SelectedRows) { string refno = row.Cells[6].Value.ToString().Trim(); string query = string.Format("update TB_CM_DEBIT set d_status = N'已發送', d_mcstatus = N'處理中' where d_docno = '{0}'", refno); DataServiceCM.GetInstance().ExecuteNonQuery(query); } MessageBox.Show("Record has been sent"); LoadData(); }
public static int GetId() { string query = "select top 1 d_id from TB_CM_DEBIT order by d_id desc"; try { int result = (int)DataServiceCM.GetInstance().ExecuteScalar(query); return(result); } catch { return(1); } }
private void printToolStripMenuItem_Click(object sender, EventArgs e) { foreach (DataGridViewRow row in dgvForm.SelectedRows) { string refno = row.Cells[6].Value.ToString().Trim(); string query = string.Format("select d_directory from TB_CM_DEBIT where d_docno = '{0}'", refno); string file = DataServiceCM.GetInstance().ExecuteScalar(query).ToString().Trim(); Process.Start(file); } LoadData(); }
private void LoadCategory() { cbCategory.Items.Add("All"); string query = "select distinct d_category from TB_CM_MASTER_DESCRIPTION"; using (IDataReader reader = DataServiceCM.GetInstance().ExecuteReader(query)) { while (reader.Read()) { cbCategory.Items.Add(reader.GetString(0).Trim()); } } cbCategory.SelectedIndex = 0; }
public static bool IsAccountCodeExists(string accountcode) { string query = string.Format("select * from TB_CM_MASTER_ACCOUNTCODE where a_code = '{0}'", accountcode); using (SqlDataReader reader = DataServiceCM.GetInstance().ExecuteReader(query)) { if (reader.HasRows) { return(true); } else { return(false); } } }
public static bool IsVendorExists(string vendor) { string query = string.Format("select * from TB_ACC_MASTER_VENDOR where v_code = '{0}'", vendor); using (SqlDataReader reader = DataServiceCM.GetInstance().ExecuteReader(query)) { if (reader.HasRows) { return(true); } else { return(false); } } }
private void SearchData(string category, string source) { DataTable table = new DataTable(); if (category == "All") { category = ""; } string query = string.Format("select d_category as category, d_desc as reason from TB_CM_MASTER_DESCRIPTION where d_category like '%{0}%' and d_r3 like '%{1}%'", category, source); SqlDataAdapter sda = new SqlDataAdapter(query, DataServiceCM.GetInstance().Connection); sda.Fill(table); dgvDescrption.DataSource = table; }
public static bool IsInvoiceExists(string invoice, string vendor) { string query = string.Format("select * from TB_ACC_MASTER_INVOICE where i_invoice = '{0}' and i_vendor = '{1}'", invoice, vendor); using (SqlDataReader reader = DataServiceCM.GetInstance().ExecuteReader(query)) { if (reader.HasRows) { return(true); } else { return(false); } } }
private void btnReject_Click(object sender, EventArgs e) { string now = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); string text = _status == "科責承認中" ? string.Format("update TB_ACC_OUTSTANDING set o_divapproval = 'No', o_divapprovaldate = '{0}', o_status = N'科責已拒絕' where o_invoice = '{1}'", now, _invoice) : _status == "會計處理中" ? string.Format("update TB_ACC_OUTSTANDING set o_staffapproval = 'No', o_staffapprovaldate = '{0}', o_status = N'會計已拒絕' where o_invoice = '{1}'", now, _invoice) : string.Format("update TB_ACC_OUTSTANDING set o_accapproval = 'No', o_accapprovaldate = '{0}', o_status = N'會計已拒絕' where o_invoice = '{1}'", now, _invoice); DataServiceCM.GetInstance().ExecuteNonQuery(text); string applicant = AccUtil.GetApplicant(_invoice); EformUtil.SendRejectEmail(_invoice, GlobalService.User, AdUtil.GetEmailByUsername(GlobalService.User, "kmhk.local"), AdUtil.GetEmailByUsername(applicant, "kmhk.local"), "Outstanding Slip Rejected - " + _invoice, "Your Outstanding Slip has been rejected by " + GlobalService.User); DialogResult = DialogResult.OK; }
public static string GetNextDocNo() { string query = "select top 1 d_id from TB_CM_DEBIT order by d_id desc"; try { int result = (int)DataServiceCM.GetInstance().ExecuteScalar(query); result += 1; return("DB-" + result.ToString("D5")); } catch { return("DB-000001"); } }
public static bool IsCostCentreExists(string costcentre) { string query = string.Format("select * from TB_CM_MASTER_COSTCENTRE where c_code = '{0}'", costcentre); using (SqlDataReader reader = DataServiceCM.GetInstance().ExecuteReader(query)) { if (reader.HasRows) { return(true); } else { return(false); } } }
private void btnApprove_Click(object sender, EventArgs e) { string query = string.Format("select d_div, d_dept, d_mcstaff, d_mcreviewer, d_mcfinal, d_createdby, d_reason from TB_CM_DEBIT where d_docno = '{0}'", _docno); string target = ""; string applicant = ""; string reason = ""; using (IDataReader reader = DataServiceCM.GetInstance().ExecuteReader(query)) { while (reader.Read()) { target = _status == "係責承認中" ? reader.GetString(0).Trim() : _status == "科責承認中" ? reader.GetString(1).Trim() : _status == "部責承認中" ? reader.GetString(2).Trim() : _status == "經管確認中" ? reader.GetString(3).Trim() : _status == "經管檢查中" ? reader.GetString(4).Trim() : ""; applicant = reader.GetString(5).Trim(); reason = reader.GetString(6).Trim(); } } string now = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); string text = _status == "係責承認中" ? string.Format("update TB_CM_DEBIT set d_status = N'科責承認中', d_sectapproval = 'Yes', d_sectdate = '{0}' where d_docno = '{1}'", now, _docno) : _status == "科責承認中" ? string.Format("update TB_CM_DEBIT set d_status = N'部責承認中', d_divapproval = 'Yes', d_divdate = '{0}' where d_docno = '{1}'", now, _docno) : _status == "部責承認中" ? string.Format("update TB_CM_DEBIT set d_status = N'經管確認中', d_deptapproval = 'Yes', d_deptdate = '{0}' where d_docno = '{1}'", now, _docno) : _status == "經管檢查中" ? string.Format("update TB_CM_DEBIT set d_status = N'經管承認中', d_mcreviewerapproval = 'Yes', d_mcreviewerdate = '{0}' where d_docno = '{1}'", now, _docno) : string.Format("update TB_CM_DEBIT set d_status = '申請處理完成', d_mcfinalapproval = 'Yes', d_mcfinaldate = '{0}' where d_docno = '{1}'", now, _docno); DataServiceCM.GetInstance().ExecuteNonQuery(text); string email = AdUtil.GetEmailByUsername(target, "kmhk.local"); string fromEmail = AdUtil.GetEmailByUsername(applicant, "kmhk.local"); if (_status == "部責承認中") { EformUtil.SendApprovalEmail(_docno, applicant, fromEmail, email, reason, "Debit Note Application Approval Required: " + _docno); } else { EformUtil.SendDebitNotificationEmail(_docno, applicant, fromEmail, email, "Received a Debit/Credit Note Application Form\n\nPlease check in Management Console"); } DialogResult = DialogResult.OK; }