public static object ExecuteScalar(string pScalarQuery) { object ret = null; try { SqlCommand myCommand = new SqlCommand(pScalarQuery, Conection); if (Conection.State == ConnectionState.Closed) { Conection.Open(); } ret = myCommand.ExecuteScalar(); Conection.Close(); return(ret); } catch (SqlException ex) { TLog.WriteErr("MyTable:ExecuteScalar()", ex.Message); if (Conection.State == ConnectionState.Open) { Conection.Close(); } } return(ret); }
public bool UpdateAdd() { bool ret = true; try { Adapter.Update(this); this.AcceptChanges(); //Lay gia tri AutoNumber mới vừa thêm >>> cập nhật vào DataTable if (this.PrimaryKey[0].AutoIncrement) { SqlCommand cmd = new SqlCommand("Select @@IDENTITY", Conection); this.Rows[RowCount - 1][0] = cmd.ExecuteScalar(); this.AcceptChanges(); } } catch (Exception ex) { TLog.WriteErr("", ex.Message); this.RejectChanges(); ret = false; } return(ret); }
public static int ExecuteNonQuery(string pNonQuery) { int ret = -1; try { SqlCommand myCommand = new SqlCommand(pNonQuery, Conection); if (Conection.State == ConnectionState.Closed) { Conection.Open(); } ret = myCommand.ExecuteNonQuery(); Conection.Close(); return(ret); } catch (SqlException ex) { TLog.WriteErr("MyTable:ExecuteNonQuery()", ex.Message); if (Conection.State == ConnectionState.Open) { Conection.Close(); } } return(ret); }
public void loadnhacungcap() { try { HH = tKH.GetKH(); if (HH != null) { lvhanghoa.Items.Clear(); for (int i = 0; i < HH.Rows.Count; i++) { int stt = i + 1; ListViewItem item = new ListViewItem(stt.ToString()); lvhanghoa.Items.Add(item); item.SubItems.Add(HH.Rows[i]["CODEKH"].ToString().Trim()); item.SubItems.Add(HH.Rows[i]["TEN"].ToString().Trim()); item.SubItems.Add(HH.Rows[i]["MST"].ToString().Trim()); item.SubItems.Add(HH.Rows[i]["TENNHOM"].ToString().Trim()); item.SubItems.Add(HH.Rows[i]["TENTT"].ToString().Trim()); item.SubItems.Add(HH.Rows[i]["DIACHI"].ToString().Trim()); item.SubItems.Add(HH.Rows[i]["DIENTHOAI"].ToString().Trim()); item.SubItems.Add(HH.Rows[i]["HANNO"].ToString().Trim()); item.SubItems.Add(HH.Rows[i]["MANHOM"].ToString().Trim()); item.SubItems.Add(HH.Rows[i]["MATINH"].ToString().Trim()); item.SubItems.Add(HH.Rows[i]["MAKH"].ToString().Trim()); } } } catch (Exception ex) { TLog.WriteErr("frmKhachHang_loadnhacungcap", ex.Message + "|" + ex.StackTrace); } }
public void DeleteKH() { try { tKH.DeleteKH(infoKH); } catch (Exception ex) { TLog.WriteErr("frmKhachHang_DeleteKH", ex.Message + "|" + ex.StackTrace); } }
public void LoadKM(int t1, int t2) { try { dt = tKM.GetKM(t1, t2); if (dt != null) { lvhanghoa.Items.Clear(); for (int i = 0; i < dt.Rows.Count; i++) { int stt = i + 1; ListViewItem item = new ListViewItem(stt.ToString()); lvhanghoa.Items.Add(item); item.SubItems.Add(dt.Rows[i]["TENHH"].ToString().Trim()); item.SubItems.Add(dt.Rows[i]["TenDV"].ToString().Trim()); item.SubItems.Add(dt.Rows[i]["SL"].ToString().Trim()); item.SubItems.Add(dt.Rows[i]["TENHHKM"].ToString().Trim()); item.SubItems.Add(dt.Rows[i]["TenDVKM"].ToString().Trim()); item.SubItems.Add(dt.Rows[i]["SLKM"].ToString().Trim()); item.SubItems.Add(String.Format("{0:dd/MM/yyyy}", dt.Rows[i]["NgayKM"].ToString().Trim())); } } } catch (Exception ex) { TLog.WriteErr("frmKhuyenMai_Load", ex.Message + "|" + ex.StackTrace); } }
public void LoadTDV() { try { tblTDV = new TblTDV(1); if (tblTDV != null) { lvTDV.Items.Clear(); for (int i = 0; i < tblTDV.Rows.Count; i++) { int stt = i + 1; ListViewItem item = new ListViewItem(stt.ToString()); lvTDV.Items.Add(item); // item.SubItems.Add(stt.ToString()); item.SubItems.Add(tblTDV.Rows[i]["MA_TDV"].ToString().Trim()); item.SubItems.Add(tblTDV.Rows[i]["TEN"].ToString().Trim()); item.SubItems.Add(tblTDV.Rows[i]["TENDANGNHAP"].ToString().Trim()); string date = String.Format("{0:dd/MM/yyyy}", tblTDV.Rows[i]["TUOI"]); item.SubItems.Add(date); item.SubItems.Add(tblTDV.Rows[i]["CHUCVU"].ToString().Trim()); item.SubItems.Add(tblTDV.Rows[i]["PHONGBAN"].ToString().Trim()); item.SubItems.Add(tblTDV.Rows[i]["SDT"].ToString().Trim()); item.SubItems.Add(tblTDV.Rows[i]["DIACHI"].ToString().Trim()); } } } catch (Exception ex) { TLog.WriteErr("frmTDV_LoadTDV", ex.Message + "|" + ex.StackTrace); } }
private void cmdTim_Click(object sender, EventArgs e) { try { if (rdMaKH.Checked == true) { if (CheckForm(1)) { DataTable dt = tKH.GetKhachHang(txtMaKH.Text); cmbKH.Text = dt.Rows[0]["TEN"].ToString(); int ma = int.Parse(dt.Rows[0]["MAKH"].ToString()); HDXuat_No(ma); } } else { cmbKH_SelectedIndexChanged(null, null); } } catch (Exception ex) { TLog.WriteErr("frmCongNo_Tim", ex.Message + "|" + ex.StackTrace); } }
private void RowUpdated(object sender, System.Data.SqlClient.SqlRowUpdatedEventArgs e) { if (GetAutoNumber) { if (e.Status == UpdateStatus.Continue & e.StatementType == StatementType.Insert) { try { //Lay gia tri AutoNumber ID if (this.PrimaryKey[0].AutoIncrement) { SqlCommand cmd = new SqlCommand("Select @@IDENTITY", Conection); e.Row.Table.Columns[0].ReadOnly = false; Object retID = cmd.ExecuteScalar(); if (retID != null) { e.Row[0] = Convert.ToInt16(retID); e.Row.AcceptChanges(); } } } catch (Exception ex) { TLog.WriteErr("MyTable:RowUpdated()", ex.Message); } } } }
static PostProcessTextOnStartup() { // Update frames and blueprints that were implicitly generated for defs with CompProperties_PostProcessText. // These are generated before ResolveReferences are ever called. foreach (var def in DefDatabase <ThingDef> .AllDefsListForReading) { if (def.entityDefToBuild is ThingDef entityDef && CompProperties_PostProcessText.defToComp.TryGetValue(entityDef, out var postProcessTextComp)) { var newLabel = entityDef.label + (postProcessTextComp.origLabel.NullOrEmpty() ? def.label : def.label.Substring(postProcessTextComp.origLabel.Length)); if (TLog.Enabled) { TLog.Log(typeof(PostProcessTextOnStartup), string.Format("{0}.label: {1} => {2}", def, CompProperties_PostProcessText.QuoteString(def.label), CompProperties_PostProcessText.QuoteString(newLabel))); } def.label = newLabel; } } // Comps add overhead, so since we're done, remove the comps now that they're no longer needed. foreach (var(def, postProcessTextComp) in CompProperties_PostProcessText.defToComp) { if (TLog.Enabled) { TLog.Log(typeof(PostProcessTextOnStartup), $"Removing {postProcessTextComp} from {def}"); } def.comps.Remove(postProcessTextComp); } CompProperties_PostProcessText.defToComp.Clear(); }
public void LoadChucNang() { lvChucNang.Items.Clear(); try { DataTable dt = tPhanQuyen.GetChuNang(); if (dt != null) { lvChucNang.Items.Clear(); for (int i = 0; i < dt.Rows.Count; i++) { int stt = i + 1; ListViewItem item = new ListViewItem(""); lvChucNang.Items.Add(item); // item.SubItems.Add(stt.ToString()); item.SubItems.Add(stt.ToString()); item.SubItems.Add(dt.Rows[i]["TEN"].ToString().Trim()); item.SubItems.Add(dt.Rows[i]["MA"].ToString().Trim()); } } } catch (Exception ex) { TLog.WriteErr("frmPhanQuyen_LoadChucNang", ex.Message + "|" + ex.StackTrace); } }
private void cmdXoaCT_Click(object sender, EventArgs e) { try { for (int i = 0; i < lvCTHD.Items.Count; i++) { if (lvCTHD.Items[i].Selected == true) { double tienCK = double.Parse(CTHD.Rows[i]["TIENCHUAVAT"].ToString()) * double.Parse(CTHD.Rows[i]["CHIETKHAU"].ToString()); double tienHH = double.Parse(CTHD.Rows[i]["TIENCOVAT"].ToString()); tNhapKho.UpdateTongtienHD(infoHDNhap.Ma, tienHH, 1); tNhapKho.DeleteCTHD(lvCTHD.Items[i].SubItems[8].Text); //I show here the second field text (SubItems[1].Text) from the selected row(Items[i]) // MessageBox.Show(lvCTHD.Items[i].SubItems[1].Text); // utlEy.DeleteEmployee(lvEmployee.Items[i].SubItems[2].Text); } } LoadCTHD(infoHDNhap.Ma.ToString()); } catch (Exception ex) { MessageBox.Show("Kiểm tra lại thông tin"); TLog.WriteErr("frmNhapkho_cmdXoaCT_Click", ex.Message + "||" + ex.StackTrace); } }
private void cmdLuu_Click(object sender, EventArgs e) { try { DataTable tb = (DataTable)dgvKho.DataSource; if (tb != null) { for (int i = 0; i < tb.Rows.Count; i++) { if (isModifedRow(tb.Rows[i])) { Pharmacy.Info.KhoInfo info = SetInfo(tb, i, 0); tKho.UpdateKho(info); //tpriceUnit.Update_priceunit1(int.Parse(tb.Rows[i]["ID"].ToString()), // float.Parse(tb.Rows[i]["Price"].ToString()), DateTime.Now); } if (isNewRow(tb.Rows[i])) { Pharmacy.Info.KhoInfo info = SetInfo(tb, i, 1); tKho.InsertKho(info); } if (isDeletedRow(tb.Rows[i])) { Pharmacy.Info.KhoInfo info = SetInfoDelete(tb, i); tKho.UpdateKho(info); } } } ShowKho(); } catch (Exception ex) { TLog.WriteErr("frmKho_SetInfo", ex.Message + "|" + ex.StackTrace); } }
public void ShowPhieuThu(DateTime date, int flag) { try { DataTable dt = tPhieuThu.GetPhieuThu_Date(date, flag); if (dt != null) { lvDisplayPhieuThu.Items.Clear(); for (int i = 0; i < dt.Rows.Count; i++) { int stt = i + 1; ListViewItem item = new ListViewItem(stt.ToString()); lvDisplayPhieuThu.Items.Add(item); // item.SubItems.Add(stt.ToString()); item.SubItems.Add(dt.Rows[i]["MA"].ToString().Trim()); item.SubItems.Add(dt.Rows[i]["TEN"].ToString().Trim()); item.SubItems.Add(dt.Rows[i]["TongTien"].ToString().Trim()); item.SubItems.Add(dt.Rows[i]["NgayThu"].ToString().Trim()); item.SubItems.Add(dt.Rows[i]["LyDo"].ToString().Trim()); item.SubItems.Add(dt.Rows[i]["KemTheo"].ToString().Trim()); } } } catch (Exception ex) { TLog.WriteErr("frmPHIEUTHU_LoadHD_No", ex.Message + "|" + ex.StackTrace); } }
/// <summary> /// Do actual call of transductor method with parameter substitution /// </summary> /// <param name="aContext">Deriving context</param> /// <returns>List of symbols produced by transductor</returns> protected override IDerivation ExpandRnd(DerivationContext aContext) { //1. Substitute and prepare parameters form context by conf xml object[] parametrs = ParamsArray(aContext); if (mTargetAccess != null) { IDerivation lDeriv = mTargetAccess.Expand(aContext); mGrammar.ListTrans.TargetList = (ListDerivation)lDeriv; } mGrammar.SysTrans.Context = aContext; string lStrResult;// = "no trans result!!!"; //2. do actual call try { object lRetVal = mBindedMethod.Invoke(mTransductorClass, parametrs); if (lRetVal is int) { return(new ExprInt((int)lRetVal)); } lStrResult = Convert.ToString(lRetVal); } catch (Exception ex) { while (ex.InnerException != null) { ex = ex.InnerException; } lStrResult = ex.Message; } TLog.Write("T", lStrResult); return(new TextDerivation(lStrResult)); }
public void LoadNhomHH() { try { tblNhomHH = new MyTable.TblNhomHH(int.Parse(cmb_loai.SelectedValue.ToString()), 1); if (tblNhomHH != null) { lvNhomHH.Items.Clear(); for (int i = 0; i < tblNhomHH.Rows.Count; i++) { int stt = i + 1; ListViewItem item = new ListViewItem(stt.ToString()); lvNhomHH.Items.Add(item); // item.SubItems.Add(stt.ToString()); item.SubItems.Add(tblNhomHH.Rows[i]["TEN"].ToString().Trim()); item.SubItems.Add(tblNhomHH.Rows[i]["MOTA"].ToString().Trim()); item.SubItems.Add(tblNhomHH.Rows[i]["MA"].ToString().Trim()); } } } catch (Exception ex) { TLog.WriteErr("frmNHOMHH_LoadNHOMHH", ex.Message + "|" + ex.StackTrace); } }
public void loadnhomkh() { try { HH = tNhomKH.GetNhomKH(); if (HH != null) { lvhanghoa.Items.Clear(); for (int i = 0; i < HH.Rows.Count; i++) { int stt = i + 1; ListViewItem item = new ListViewItem(stt.ToString()); lvhanghoa.Items.Add(item); item.SubItems.Add(HH.Rows[i]["TEN"].ToString().Trim()); item.SubItems.Add(HH.Rows[i]["MOTA"].ToString().Trim()); item.SubItems.Add(HH.Rows[i]["MANHOMKH"].ToString().Trim()); } } } catch (Exception ex) { TLog.WriteErr("frmNhomKH_loadnhomkh", ex.Message + "|" + ex.StackTrace); } }
protected override IDerivation ExpandRnd(DerivationContext aContext) { if (IsTerminal) { TLog.Write("T", Text); return(new TextDerivation(Text)); } else { // искать правило if (mGrammar.mRules.ContainsKey(Text)) { Rule lRule = mGrammar.mRules[Text]; TreeNode lNewNode = new TreeNode(Text); aContext.RuleDerivNode.Nodes.Add(lNewNode); DerivationContext lNewContext = new DerivationContext(aContext); lNewContext.RuleDerivNode = lNewNode; lNewContext.ExpandingRuleSymbol = this; IDerivation lRuleResult = lRule.Expand(lNewContext); mGrammar.RuleProtocol.Add(Text, lRuleResult, aContext); return(lRuleResult); // Expand(lRuleResult, aContext); } else { // нашли нетерм. символ, который нельзя раскрыть throw new GrammarDeductException(string.Format("Не определен нетерминальный символ {0}", Text)); } } }
private void cmdXoaCT_Click(object sender, EventArgs e) { try { for (int i = 0; i < lvCTHD.Items.Count; i++) { if (lvCTHD.Items[i].Selected == true) { int sl = int.Parse(lvCTHD.Items[i].SubItems[4].Text); double tienCK = double.Parse(CTHD.Rows[i]["TIENCHUAVAT"].ToString()) * double.Parse(CTHD.Rows[i]["CHIETKHAU"].ToString()); double tienHH = double.Parse(CTHD.Rows[i]["TIENCOVAT"].ToString()); tXuatKho.UpdateTongtienHD(infoHDXUAT.Ma, tienHH, 1); Delete(lvCTHD.Items[i].SubItems[7].Text, sl); if (i + 1 < lvCTHD.Items.Count) { sl = int.Parse(lvCTHD.Items[i + i].SubItems[4].Text); int dongia = int.Parse(lvCTHD.Items[i + 1].SubItems[5].Text); int tien = int.Parse(lvCTHD.Items[i + 1].SubItems[6].Text); if (dongia == 0 && tien == 0) { Delete(lvCTHD.Items[i + 1].SubItems[7].Text, sl); } } cmbLo_SelectedIndexChanged(null, null); } } LoadCTHD(int.Parse(infoHDXUAT.Ma.ToString())); } catch (Exception ex) { TLog.WriteErr("frmXuatKho_cmdXoaCT_Click", ex.Message + "|" + ex.StackTrace); } }
public void LoadNCC() { try { tblNCC = new TblNCC(1); if (tblNCC != null) { lvNCC.Items.Clear(); for (int i = 0; i < tblNCC.Rows.Count; i++) { string _Qg = tblNCC.GetQuocGia(tblNCC.Rows[i]["MAQG"]); int stt = i + 1; ListViewItem item = new ListViewItem(stt.ToString()); lvNCC.Items.Add(item); // item.SubItems.Add(stt.ToString()); item.SubItems.Add(tblNCC.Rows[i]["CODENCC"].ToString().Trim()); item.SubItems.Add(tblNCC.Rows[i]["TEN"].ToString().Trim()); item.SubItems.Add(tblNCC.Rows[i]["MANHOM"].ToString().Trim()); item.SubItems.Add(_Qg); item.SubItems.Add(tblNCC.Rows[i]["DIACHI"].ToString().Trim()); item.SubItems.Add(tblNCC.Rows[i]["DIENTHOAI"].ToString().Trim()); item.SubItems.Add(tblNCC.Rows[i]["MST"].ToString().Trim()); } } } catch (Exception ex) { TLog.WriteErr("frmNCC_LoadNCC", ex.Message + "|" + ex.StackTrace); } }
public void ShowInfoLo(string MaLo) { int i = 0; for (i = 0; i < LO.Rows.Count; i++) { if (LO.Rows[i]["MALO"].ToString() == MaLo) { break; } } try { txtSL.Text = LO.Rows[i]["SLTON_LO"].ToString(); slton = int.Parse(LO.Rows[i]["SLTON_LO"].ToString()); cmbDVT.Text = LO.Rows[i]["TENDV"].ToString(); dpkHH.Text = LO.Rows[i]["NGAYHH"].ToString(); txtKho.Text = LO.Rows[i]["TEN"].ToString(); txtKe.Text = LO.Rows[i]["KE"].ToString(); maCTkho = int.Parse(LO.Rows[i]["MACTKHO"].ToString()); } catch (Exception ex) { TLog.WriteErr("frmXuatKho_ShowinfoLo", ex.Message); } }
public void InsertCTHD() { try { if (CheckCTHD()) { SetInfoCTXUAT(); tXuatKho.InsertCTNHAP(infoCTXuat); txtTongTien.Text = (double.Parse(txtTongTien.Text) + double.Parse(txtGia.Text)).ToString(); tXuatKho.UpdateTongtienHD(infoHDXUAT.Ma, float.Parse(txtTongTien.Text), 0); slton = slton - int.Parse(txtSLban.Text); UpdateLo(int.Parse(cmbLo.SelectedValue.ToString()), slton, 0); ////////////////////////////// SetHHKhuyenMai(); } else { MessageBox.Show("Vui lòng điền đầy đủ thông tin"); } } catch (Exception ex) { MessageBox.Show("Kiểm tra lại thông tin"); TLog.WriteErr("frmXuatKho_InsertCTHD", ex.Message + "|" + ex.StackTrace); } }
public void loadnhasanxuat() { try { HH = tNSX.GetNSX(); if (HH != null) { lvhanghoa.Items.Clear(); for (int i = 0; i < HH.Rows.Count; i++) { int stt = i + 1; ListViewItem item = new ListViewItem(stt.ToString()); lvhanghoa.Items.Add(item); item.SubItems.Add(HH.Rows[i]["TENSX"].ToString().Trim()); item.SubItems.Add(HH.Rows[i]["TEN"].ToString().Trim()); item.SubItems.Add(HH.Rows[i]["DIENTHOAI"].ToString().Trim()); item.SubItems.Add(HH.Rows[i]["MA"].ToString().Trim()); } } } catch (Exception ex) { TLog.WriteErr("frmNSX_loadnsx", ex.Message + "|" + ex.StackTrace); } }
public bool Restore(string path) { Connect(); if (srvSql != null) { try // If the user has chosen the file from which he wants the database to be restored { // Create a new database restore operation Restore rstDatabase = new Restore(); // Set the restore type to a database restore rstDatabase.Action = RestoreActionType.Database; // Set the database that we want to perform the restore on rstDatabase.Database = DBName; BackupDeviceItem bkpDevice = new BackupDeviceItem(path, DeviceType.File); // Add the backup device to the restore type rstDatabase.Devices.Add(bkpDevice); // If the database already exists, replace it rstDatabase.ReplaceDatabase = true; // Perform the restore rstDatabase.SqlRestore(srvSql); } catch (Exception ex) { TLog.WriteErr("TBackup.cs_retore ", ex.Message); return(false); } } else { TLog.WriteErr("TBackup.cs_retore ", "Not Connected to Server"); return(false); } return(true); }
private void InsertCTPhieuThu(int ma) { Info.CTPHIEUTHU info = new Info.CTPHIEUTHU(); if (rdKH.Checked == true) { for (int i = 0; i < lvThu.Items.Count; i++) { try { info = SetInfoCTPIEUTHU(ma, lvThu.Items[i].SubItems[1].Text, float.Parse(lvThu.Items[i].SubItems[2].Text)); BLL.TPhieuThu tPhieuThu = new BLL.TPhieuThu(); tPhieuThu.InsertCT_PHIEUTHU(info); } catch (Exception ex) { TLog.WriteErr("frmPHIEUTHU_InsertCTPhieuThu", ex.Message + "|" + ex.StackTrace); } } } else { try { info = SetInfoCTPIEUTHU(ma, DBNull.Value.ToString(), float.Parse(txtTongTien.Text)); BLL.TPhieuThu tPhieuThu = new BLL.TPhieuThu(); tPhieuThu.InsertCT_PHIEUTHU(info); } catch (Exception ex) { TLog.WriteErr("frmPHIEUTHU_InsertCTPhieuThu", ex.Message + "|" + ex.StackTrace); } } }
public void CheckLogin() { try { DataTable dt = tLogin.CheckMatKhau(txtUser.Text.Trim(), txtPass.Text.Trim()); if (dt.Rows.Count > 0) { refesh(); maTDV = int.Parse(dt.Rows[0]["MA"].ToString()); tenDN = dt.Rows[0]["TEN"].ToString(); this.Hide(); frmMain frm = new frmMain(); frm.Show(this, maTDV, tenDN); frm.FormClosed += new FormClosedEventHandler(frm_FormClosed); } else { MessageBox.Show("Thông tin đăng nhập không hợp lệ!"); } } catch (Exception ex) { TLog.WriteErr("frmDangNhap_CheckLogin", ex.Message + "|" + ex.StackTrace); } }
private void cmdTheKho_Click(object sender, EventArgs e) { try { Showreport(int.Parse(txtThang.Text.ToString()), int.Parse(txtNam.Text.ToString())); } catch (Exception ex) { TLog.WriteErr("frmfptTonKho_click", ex.Message); } }
public void Execute(IJobExecutionContext context) { TLog.SaveLog("定时器正执行指定任务..."); string retInfo = ""; ShopStatisticHelper.AutoStatisticsOrders(out retInfo); TLog.SaveLog("任务执行完毕。结果:" + retInfo); }
public void DeleteNhomKH() { try { tNhomKH.DeleteNhomKH(infoNhomKH); } catch (Exception ex) { TLog.WriteErr("frmNhomKH_DeleteNhomKH", ex.Message + "|" + ex.StackTrace); } }
public void InsertHDNhap() { try { infoHDNhap.Ma = tNhapKho.InsertHDNHAP(infoHDNhap); } catch (Exception ex) { MessageBox.Show("Kiểm tra lại thông tin"); TLog.WriteErr("frmNhapkho_InsertHDNhap", ex.Message + "||" + ex.StackTrace); } }