예제 #1
0
        private List <SYS_COMPANY> MapSYS_COMPANY(DataTable dt)
        {
            List <SYS_COMPANY> rs = new List <SYS_COMPANY>();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                SYS_COMPANY obj = new SYS_COMPANY();
                if (dt.Columns.Contains("Company_Id"))
                {
                    obj.Company_Id = dt.Rows[i]["Company_Id"].ToString();
                }
                if (dt.Columns.Contains("Company"))
                {
                    obj.Company = dt.Rows[i]["Company"].ToString();
                }
                if (dt.Columns.Contains("Address"))
                {
                    obj.Address = dt.Rows[i]["Address"].ToString();
                }
                if (dt.Columns.Contains("Tel"))
                {
                    obj.Tel = dt.Rows[i]["Tel"].ToString();
                }
                if (dt.Columns.Contains("Fax"))
                {
                    obj.Fax = dt.Rows[i]["Fax"].ToString();
                }
                if (dt.Columns.Contains("WebSite"))
                {
                    obj.WebSite = dt.Rows[i]["WebSite"].ToString();
                }
                if (dt.Columns.Contains("Email"))
                {
                    obj.Email = dt.Rows[i]["Email"].ToString();
                }
                if (dt.Columns.Contains("Tax"))
                {
                    obj.Tax = dt.Rows[i]["Tax"].ToString();
                }
                if (dt.Columns.Contains("Licence"))
                {
                    obj.Licence = dt.Rows[i]["Licence"].ToString();
                }
                if (dt.Columns.Contains("Photo"))
                {
                    obj.Photo = (byte[])(dt.Rows[i]["Photo"]);
                }

                rs.Add(obj);
            }
            return(rs);
        }
예제 #2
0
 private void frmThongTin_Load(object sender, EventArgs e)
 {
     objsyscompany = new SYS_COMPANYController().SYS_COMPANY_Get("01");
     if (objsyscompany.Company_Id == "01")
     {
         MemoryStream fs1 = new MemoryStream(objsyscompany.Photo, true);
         pictureEdit1.Image = Image.FromStream(fs1);
         pictureEdit1.Refresh();
         txtTen.Text       = objsyscompany.Company;
         txtDiaChi.Text    = objsyscompany.Address;
         txtDienthoai.Text = objsyscompany.Tel;
         txtEmail.Text     = objsyscompany.Email;
         txtFax.Text       = objsyscompany.Fax;
         txtMST.Text       = objsyscompany.Tax;
         txtWebsite.Text   = objsyscompany.WebSite;
         txtGP.Text        = objsyscompany.Licence;
     }
 }
예제 #3
0
 public int SYS_COMPANY_Insert(SYS_COMPANY obj)
 {
     try
     {
         return(DataProvider.ExecuteNonquery(DataProvider.ConnectionString, "SYS_COMPANY_Insert",
                                             obj.Company_Id,
                                             obj.Company,
                                             obj.Address,
                                             obj.Tel,
                                             obj.Fax,
                                             obj.WebSite,
                                             obj.Email,
                                             obj.Tax,
                                             obj.Licence,
                                             obj.Photo
                                             ));
     }
     catch
     {
         //throw ex;
         return(-1);
     }
 }
예제 #4
0
 private void simpleButton1_Click(object sender, EventArgs e)
 {
     objsyscompany = new SYS_COMPANYController().SYS_COMPANY_Get("01");
     if (objsyscompany.Company_Id != "01")
     {
         int        rs = -1;
         FileStream frm;
         frm = new FileStream(Pathname, FileMode.Open, FileAccess.Read);
         byte[] picbyte = new byte[frm.Length];
         frm.Read(picbyte, 0, System.Convert.ToInt32(frm.Length));
         frm.Close();
         objsyscompany.Company_Id = "01";
         objsyscompany.Company    = txtTen.Text;
         objsyscompany.Address    = txtDiaChi.Text;
         objsyscompany.Fax        = txtFax.Text;
         objsyscompany.Email      = txtEmail.Text;
         objsyscompany.Tel        = txtDienthoai.Text;
         objsyscompany.Tax        = txtMST.Text;
         objsyscompany.WebSite    = txtWebsite.Text;
         objsyscompany.Licence    = txtMST.Text;
         objsyscompany.Photo      = picbyte;
         rs = new SYS_COMPANYController().SYS_COMPANY_Insert(objsyscompany);
         if (rs < 1)
         {
             MessageBox.Show("Công ty đã tồn tại", "Thông báo");
         }
         else
         {
             MessageBox.Show("Công ty mới đã được lưu", "Thông báo");
         }
     }
     else
     {
         int rs = -1;
         if (Pathname != null)
         {
             FileStream frm;
             frm = new FileStream(Pathname, FileMode.Open, FileAccess.Read);
             byte[] picbyte = new byte[frm.Length];
             frm.Read(picbyte, 0, System.Convert.ToInt32(frm.Length));
             frm.Close();
             objsyscompany.Photo = picbyte;
         }
         objsyscompany.Company_Id = "01";
         objsyscompany.Company    = txtTen.Text;
         objsyscompany.Address    = txtDiaChi.Text;
         objsyscompany.Fax        = txtFax.Text;
         objsyscompany.Email      = txtEmail.Text;
         objsyscompany.Tel        = txtDienthoai.Text;
         objsyscompany.Tax        = txtMST.Text;
         objsyscompany.WebSite    = txtWebsite.Text;
         objsyscompany.Licence    = txtMST.Text;
         rs = new SYS_COMPANYController().SYS_COMPANY_Update(objsyscompany, objsyscompany.Company_Id);
         if (rs < 1)
         {
             MessageBox.Show("Công ty đã tồn tại", "Thông báo");
         }
         else
         {
             MessageBox.Show("Công ty đã cập nhật", "Thông báo");
         }
     }
 }