コード例 #1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                if (checkInput())
                {
                    switch (function)
                    {
                    case "add":
                        objLoaiTaiSan = new LoaiTaiSan();
                        setDataObj();
                        if (objLoaiTaiSan.add() > 0 && DBInstance.commit() > 0)
                        {
                            XtraMessageBox.Show("Thêm loại tài sản thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            Guid id = objLoaiTaiSan.id;
                            reLoadAndSelectNode(id);
                        }
                        else
                        {
                            XtraMessageBox.Show("Thêm loại tài sản không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        break;

                    case "edit":
                        setDataObj();
                        if (objLoaiTaiSan.update() > 0 && DBInstance.commit() > 0)
                        {
                            XtraMessageBox.Show("Sửa loại tài sản thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            Guid id = objLoaiTaiSan.id;
                            reLoadAndSelectNode(id);
                        }
                        else
                        {
                            XtraMessageBox.Show("Sửa loại tài sản không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(this.Name + "->btnOk_Click: " + ex.Message);
            }
        }
コード例 #2
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     try
     {
         if (checkInput())
         {
             switch (function)
             {
                 case "add":
                     objLoaiTaiSan = new LoaiTaiSan();
                     setDataObj();
                     if (objLoaiTaiSan.add() > 0 && DBInstance.commit() > 0)
                     {
                         XtraMessageBox.Show("Thêm loại tài sản thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                         Guid id = objLoaiTaiSan.id;
                         reLoadAndSelectNode(id);
                     }
                     else
                     {
                         XtraMessageBox.Show("Thêm loại tài sản không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     }
                     break;
                 case "edit":
                     setDataObj();
                     if (objLoaiTaiSan.update() > 0 && DBInstance.commit() > 0)
                     {
                         XtraMessageBox.Show("Sửa loại tài sản thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                         Guid id = objLoaiTaiSan.id;
                         reLoadAndSelectNode(id);
                     }
                     else
                     {
                         XtraMessageBox.Show("Sửa loại tài sản không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     }
                     break;
             }
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine(this.Name + "->btnOk_Click: " + ex.Message);
     }
 }
コード例 #3
0
 public static bool ImportLoaiTS(String fileName, String sheet)
 {
     try
     {
         System.Data.DataTable dt = new System.Data.DataTable();
         const int STT = 0;
         const int TEN = 1;
         const int DONVITINH = 2;
         const int LOAI = 3;
         const int PARENT = 4;
         const int PASS = 5;
         dt = OpenFile(fileName, sheet);
         if (dt != null)
         {
             foreach (System.Data.DataRow row in dt.Rows)
             {
                 if (row[PASS] == DBNull.Value || !row[PASS].Equals("Pass"))
                 {
                     if (row[TEN] != DBNull.Value && row[LOAI] != DBNull.Value)
                     {
                         try
                         {
                             if (row[PARENT] != DBNull.Value)
                             {
                                 String tenParent = row[PARENT].ToString().Trim().ToUpper();
                                 LoaiTaiSan objParent = LoaiTaiSan.getQuery().Where(c => c.ten.ToUpper().Equals(tenParent)).FirstOrDefault();
                                 if (objParent != null)
                                 {
                                     String ten = row[TEN].ToString().Trim().ToUpper();
                                     LoaiTaiSan obj = LoaiTaiSan.getQuery().Where(c => c.ten.ToUpper().Equals(ten)).FirstOrDefault();
                                     if (obj == null)
                                     {
                                         obj = new LoaiTaiSan();
                                         obj.ten = row[TEN].ToString().Trim();
                                         obj.parent = objParent;
                                         obj.donvitinh = row[DONVITINH] != DBNull.Value ? getDonViTinh(row[DONVITINH].ToString()) : null;
                                         obj.huuhinh = Convert.ToBoolean(row[LOAI]);
                                         if (obj.add() > 0 && DBInstance.commit() > 0)
                                         {
                                             WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Pass");
                                         }
                                         else
                                         {
                                             WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error");
                                         }
                                     }
                                     else
                                     {
                                         WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Exist");
                                     }
                                 }
                                 else
                                 {
                                     WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error (Không có loại tài sản cha)");
                                 }
                             }
                             else
                             {
                                 String ten = row[TEN].ToString().Trim().ToUpper();
                                 LoaiTaiSan obj = LoaiTaiSan.getQuery().Where(c => c.ten.ToUpper().Equals(ten)).FirstOrDefault();
                                 if (obj == null)
                                 {
                                     obj = new LoaiTaiSan();
                                     obj.ten = row[TEN].ToString().Trim();
                                     obj.donvitinh = row[DONVITINH] != DBNull.Value ? getDonViTinh(row[DONVITINH].ToString()) : null;
                                     obj.huuhinh = Convert.ToBoolean(row[LOAI]);
                                     if (obj.add() > 0 && DBInstance.commit() > 0)
                                     {
                                         WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Pass");
                                     }
                                     else
                                     {
                                         WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error");
                                     }
                                 }
                                 else
                                 {
                                     WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Exist");
                                 }
                             }
                         }
                         catch (Exception ex)
                         {
                             Debug.WriteLine("ExcelDataBaseHelper->ImportDonVi: " + ex.Message);
                             WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error");
                         }
                     }
                     else
                     {
                         WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error (Không đủ thông tin)");
                     }
                 }
             }
         }
         return true;
     }
     catch (Exception ex)
     {
         Debug.WriteLine("ExcelDataBaseHelper->ImportDonVi: " + ex.Message);
         return false;
     }
 }
コード例 #4
0
 private static LoaiTaiSan getLoai(String _ten)
 {
     try
     {
         String ten = _ten.Trim();
         ten = ten.Replace("- ", "");
         LoaiTaiSan obj = LoaiTaiSan.getQuery().Where(c => c.ten.ToUpper().Equals(ten.ToUpper())).FirstOrDefault();
         if (obj == null)
         {
             obj = new LoaiTaiSan();
             obj.ten = ten;
             obj.huuhinh = true;
             obj.donvitinh = null;
             if (obj.add() > 0 && DBInstance.commit() > 0)
                 return obj;
             else return null;
         }
         return obj;
     }
     catch
     {
         return null;
     }
 }