public string GetNewSoct(string ma_qs) { string cmd; int M_AUTO_SOCT = Convert.ToInt16(BindingSysObj.GetOption("M_AUTO_SOCT").ToString()); switch (M_AUTO_SOCT) { case 1: cmd = "SELECT transform, so_ct + 1 as so_ct FROM dmqs WHERE ma_qs = '" + ma_qs.Trim() + "'"; break; default: cmd = cmd = "EXEC [GetNewSoct] '" + ma_qs.Trim() + "'"; break; } DataTable tbTmp = BindingSysObj.ExcuteReader(new SqlCommand(cmd)).Tables[0]; if (tbTmp.Rows.Count > 0) { DataRow row = tbTmp.Rows[0]; if (row[1] != null && row[1] != DBNull.Value) { string so_ct_new = row[1].ToString(); return(string.Format(row[0].ToString(), Convert.ToDouble(so_ct_new))); } } return(""); }
private void Form_Loaded(object sender, RoutedEventArgs e) { txtso_ct_pt.MaxLength = BindingSysObj.GetDatabaseFieldLength("so_ct"); txtnguoi_nop.MaxLength = BindingSysObj.GetDatabaseFieldLength("ong_ba"); txtlydo_nop.MaxLength = BindingSysObj.GetDatabaseFieldLength("dien_giai"); if (tbInfoPT == null || (tbInfoPT != null && tbInfoPT.Rows.Count == 0)) { txtKind.Value = kind; SqlCommand cmd = new SqlCommand(); cmd.CommandText = "if(select count(1) from dmqs where ma_cts LIKE '%{0}%') = 1"; cmd.CommandText += " select ma_qs from dmqs where ma_cts LIKE '%{1}%'"; if (txtKind.Value.ToString().Equals("1")) { txtMa_qs_pt.Filter = filterma_qs.Replace("HDA", "PT1"); txtMa_gd.Filter = "ma_ct = 'PT1' and status = 1 and ma_gd IN ('2','9')"; cmd.CommandText = string.Format(cmd.CommandText, "PT1", "PT1"); } else { txtMa_qs_pt.Filter = filterma_qs.Replace("HDA", "BC1"); txtMa_gd.Filter = "ma_ct = 'BC1' and status = 1 and ma_gd IN ('2','9')"; cmd.CommandText = string.Format(cmd.CommandText, "BC1", "BC1"); } txtMa_gd.Text = StartUp.CommandInfo["parameter"].ToString().Split(';')[0]; txtMa_gd.SearchInit(); txtMa_gd_PreviewLostFocus(txtMa_gd, null); DataSet ds = BindingSysObj.ExcuteReader(cmd); if (ds.Tables.Count == 1) { txtMa_qs_pt.Text = ds.Tables[0].Rows[0]["ma_qs"].ToString(); } if (StartUp.M_LAN.Equals("V")) { txtlydo_nop.Text = string.Format("Thu tiền hóa đơn số {0}, ngày {1}", so_hd, ngay_hd); } else { txtlydo_nop.Text = string.Format("Invoice no. {0}, invoice date {1}", so_hd, ngay_hd); } } else { txtKind.Value = tbInfoPT.Rows[0]["ma_ct"].ToString().Equals("PT1") ? 1 : 2; if (txtKind.Value.ToString().Equals("1")) { txtMa_qs_pt.Filter = filterma_qs.Replace("HD1", "PT1"); txtMa_gd.Filter = "ma_ct = 'PT1' and status = 1 and ma_gd IN ('2','9')"; } else { txtMa_qs_pt.Filter = filterma_qs.Replace("HD1", "BC1"); txtMa_gd.Filter = "ma_ct = 'BC1' and status = 1 and ma_gd IN ('2','9')"; } txtMa_gd.Text = tbInfoPT.Rows[0]["ma_gd"].ToString(); txtMa_gd.SearchInit(); txtMa_gd_PreviewLostFocus(txtMa_gd, null); txtMa_qs_pt.Text = tbInfoPT.Rows[0]["ma_qs"].ToString(); txtso_ct_pt.Text = tbInfoPT.Rows[0]["so_ct"].ToString().Trim(); txtnguoi_nop.Text = tbInfoPT.Rows[0]["ong_ba"].ToString(); txtlydo_nop.Text = tbInfoPT.Rows[0]["dien_giai"].ToString(); } txtMa_nt.Text = StartUp.M_MA_NT0; if (Ma_nt_ht != StartUp.M_MA_NT0) { txtMa_nt.Filter = "ma_nt IN ('" + StartUp.M_MA_NT0 + "','" + Ma_nt_ht + "')"; } else { txtMa_nt.IsReadOnly = true; txtMa_nt.IsTabStop = false; } txtKind.Focus(); }