private int GetLoaiDuLieu()
        {
            int    rs  = 0;
            string sql = "Select kh.IdKho " +
                         " From tbl_DM_Kho kh Inner Join tbl_BangGia_Kho bg On kh.IdKho = bg.IdKho " +
                         " Where kh.SuDung=1 and bg.IdBangGia = " + this.g1IdBangGia;

            if (DBTools.getValue(sql) != "")
            {
                rs = 1;
            }
            return(rs);
        }
예제 #2
0
        public static DataTable DBGetByRowID(Guid rowID)
        {
            DataTable dt = new DataTable();

            if ((Guid)Tools.isNull(rowID, Guid.Empty) != Guid.Empty)
            {
                List <Parameter> prm = new List <Parameter>();
                prm.Add(new Parameter("@RowID", SqlDbType.UniqueIdentifier, rowID));

                dt = DBTools.DBGetDataTable("usp_Perusahaan_LIST", prm);
            }
            return(dt);
        }
예제 #3
0
        private void LoadCommboLoaiThu()
        {
            //this.dtLoaiThuChi = DBTools.getData("tbl_DM_LoaiThuChi", " Select IdThuChi, Ten From tbl_DM_LoaiThuChi Where SuDung = 1 and Type = 0 ").Tables["tbl_DM_LoaiThuChi"];
            //if (this.dtLoaiThuChi != null) {
            //    this.cboLoaiThu.DataSource = dtLoaiThuChi;
            //    this.cboLoaiThu.DisplayMember = "Ten";
            //    this.cboLoaiThu.ValueMember = "IdThuChi";
            //    this.cboLoaiThu.SelectedIndex = -1;
            //}
            string sql = "Select IdThuChi, Ten From tbl_DM_LoaiThuChi Where SuDung = 1 and Type = 0 ";

            DBTools.List_LoadData(this.cboLoaiThu, sql, "IdThuChi", "Ten", " ", 0);
        }
예제 #4
0
        public static DataTable DBGetListDetail(Guid perusahaanRowID, string cabangID, DateTime?fromDate, DateTime?toDate)
        {
            DataTable        dt  = null;
            List <Parameter> prm = new List <Parameter>();

            prm.Add(new Parameter("@PerusahaanRowID", SqlDbType.UniqueIdentifier, perusahaanRowID));
            prm.Add(new Parameter("@CabangID", SqlDbType.VarChar, cabangID));
            prm.Add(new Parameter("@fromDate", SqlDbType.Date, fromDate));
            prm.Add(new Parameter("@toDate", SqlDbType.Date, toDate));

            dt = DBTools.DBGetDataTable("usp_HubunganIstimewaDetail_LIST_FILTER_Tanggal", prm);
            return(dt);
        }
예제 #5
0
        public static DataTable DBGetListPendingReconcile(Guid perusahaanRowID, string cabangID, DateTime?fromDate, DateTime?toDate)
        {
            DataTable        dt  = null;
            List <Parameter> prm = new List <Parameter>();

            prm.Add(new Parameter("@PerusahaanRowID", SqlDbType.UniqueIdentifier, perusahaanRowID));
            prm.Add(new Parameter("@CabangID", SqlDbType.VarChar, cabangID));
            prm.Add(new Parameter("@FromDate", SqlDbType.Date, fromDate));
            prm.Add(new Parameter("@ToDate", SqlDbType.Date, toDate));

            dt = DBTools.DBGetDataTable("usp_HI11_LIST_Reconcile_Pending", prm);
            return(dt);
        }
예제 #6
0
        private void LoadCommboDoiTuong()
        {
            //this.dtDoiTuong = DBTools.getData("tbl_DM_DoiTuong", "Select IdDoiTuong, MaDoiTuong + ' - ' + TenDoiTuong DoiTuong From tbl_DM_DoiTuong Where SuDung = 1").Tables["tbl_DM_DoiTuong"];
            //if (this.dtDoiTuong != null) {
            //    this.cboDoiTuong.DataSource = dtDoiTuong;
            //    this.cboDoiTuong.DisplayMember = "DoiTuong";
            //    this.cboDoiTuong.ValueMember = "IdDoiTuong";
            //    this.cboDoiTuong.SelectedIndex = -1;
            //}
            string sql = "Select IdDoiTuong, MaDoiTuong + ' - ' + TenDoiTuong DoiTuong From tbl_DM_DoiTuong Where SuDung = 1";

            DBTools.List_LoadData(this.cboDoiTuong, sql, "IdDoiTuong", "DoiTuong", " ", 0);
        }
예제 #7
0
        private void LoadData()
        {
            string    sql = "select pt.*, nv.HoTen NguoiThu from tbl_ThuChi pt inner join tbl_DM_NhanVien nv on pt.IdNhanVien= nv.IdNhanVien where " + Condition();
            DataTable dt  = DBTools.getData("tbl_ThuChi", sql).Tables["tbl_ThuChi"];

            dt.Columns.Add("SoTT", System.Type.GetType("System.Int16"));
            for (int i = 0; i <= dt.Rows.Count - 1; i++)
            {
                dt.DefaultView[i]["SoTT"] = i + 1;
            }
            dgvResult.DataSource = dt.DefaultView;
            dgvResult.Refresh();
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         // Inizializzazioni che vengono eseguite solo la prima volta che la pagina viene caricata
         DBTools myTools = new DBTools();
         lstTables.DataSource = myTools.getTableName();
         lstTables.DataBind();
         lstTables.SelectedIndex = 0;
         dgvItems.DataSource     = myTools.getTableData(lstTables.SelectedItem.ToString());
         dgvItems.DataBind();
     }
 }
        private void LoadCommboDoiTuong()
        {
            DataTable dtDoiTuong = DBTools.getData("tbl_DM_DoiTuong", "Select IdDoiTuong, MaDoiTuong + ' - ' + TenDoiTuong DoiTuong From tbl_DM_DoiTuong Where SuDung = 1").Tables["tbl_DM_DoiTuong"];

            if (dtDoiTuong != null)
            {
                dtDoiTuong.Rows.InsertAt(dtDoiTuong.NewRow(), 0);
                this.cboDoiTuong.DataSource    = dtDoiTuong;
                this.cboDoiTuong.DisplayMember = "DoiTuong";
                this.cboDoiTuong.ValueMember   = "IdDoiTuong";
                this.cboDoiTuong.SelectedIndex = -1;
            }
        }
예제 #10
0
        public static bool DeleteProjectItem(string projectName)
        {
            ///////////////////
            ///
            ///
            ///  本接口暂时未实现
            ///
            ///////////////////
            MySqlConnection con = DBTools.GetMySqlConnection();
            MySqlCommand    cmd;
            int             count = -1;

            try
            {
                con.Open();

                cmd = con.CreateCommand();

                cmd.CommandText = DELETE_PROJECT_ITEM_BY_NAME_STR;
                cmd.Parameters.AddWithValue("@ProjectName", projectName);


                count = cmd.ExecuteNonQuery();
                cmd.Dispose();

                con.Close();
                con.Dispose();

                if (count == 1)
                {
                    Console.WriteLine("删除任务工作量{0}成功", projectName);
                    return(true);
                }
                else
                {
                    Console.WriteLine("删除任务工作量{0}失败", projectName);
                    return(false);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (con.State == ConnectionState.Open)
                {
                    con.Close();
                }
            }
        }
예제 #11
0
        ///private const String GET_HSDEPARTMENT_BY_ID_STR = @"SELECT id, name, shortcall, canboundary, caninland, canemergency, canregular, highdepid FROM `department` WHERE (id = @departmentId)";
        /// <summary>
        /// 获取编号为departmentId的部门信息
        /// </summary>
        /// <param name="departmentId"></param>
        /// <returns></returns>
        public HSDepartment GetHSDepartment(int departmentId)
        {
            MySqlConnection con = DBTools.GetMySqlConnection();
            MySqlCommand    cmd;

            HSDepartment department = new HSDepartment();

            try
            {
                con.Open();

                cmd = con.CreateCommand();

                cmd.CommandText = QUERY_HSDEPARTMENT_STR;
                cmd.Parameters.AddWithValue("@departmentId", departmentId);

                MySqlDataReader sqlRead = cmd.ExecuteReader();
                cmd.Dispose();

                while (sqlRead.Read())
                {
                    ///  部门基本信息
                    department.Id        = int.Parse(sqlRead["id"].ToString());
                    department.Name      = sqlRead["name"].ToString();
                    department.ShortCall = sqlRead["shortcall"].ToString();

                    ///  申请权限信息
                    department.CanBoundary = int.Parse(sqlRead["canboundary"].ToString());
                    department.CanInland   = int.Parse(sqlRead["caninland"].ToString());

                    ///  上级部门信息
                    department.HigherDepartmentId = int.Parse(sqlRead["highdepid"].ToString());
                }


                con.Close();
                con.Dispose();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (con.State == ConnectionState.Open)
                {
                    con.Close();
                }
            }
            return(department);
        }
예제 #12
0
        public static int InsertBillReport(string str_title, string str_writer, DateTime dt_time, string str_path)
        {
            int       result    = -1;
            DBConn    dBConn    = null;
            DbCommand dbCommand = null;

            try
            {
                dBConn = DBConnPool.getConnection();
                if (dBConn.con != null)
                {
                    dbCommand = DBConn.GetCommandObject(dBConn.con);
                    if (DBUrl.SERVERMODE)
                    {
                        string commandText = "insert into reportbill(Title,Writer,ReportTime,ReportPath) values(?Title,?Writer,?ReportTime,?ReportPath)";
                        dbCommand.CommandText = commandText;
                        dbCommand.Parameters.Add(DBTools.GetParameter("?Title", str_title, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?Writer", str_writer, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?ReportTime", dt_time.ToString("yyyy-MM-dd HH:mm:ss"), dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("?ReportPath", str_path, dbCommand));
                    }
                    else
                    {
                        string commandText = "insert into reportbill(Title,Writer,ReportTime,ReportPath) values(?,?,?,?)";
                        dbCommand.CommandText = commandText;
                        dbCommand.Parameters.Add(DBTools.GetParameter("@Title", str_title, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@Writer", str_writer, dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@ReportTime", dt_time.ToString("yyyy-MM-dd HH:mm:ss"), dbCommand));
                        dbCommand.Parameters.Add(DBTools.GetParameter("@ReportPath", str_path, dbCommand));
                    }
                    result = dbCommand.ExecuteNonQuery();
                    return(result);
                }
            }
            catch (Exception ex)
            {
                DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace);
            }
            finally
            {
                if (dbCommand != null)
                {
                    dbCommand.Dispose();
                }
                if (dBConn.con != null)
                {
                    dBConn.Close();
                }
            }
            return(result);
        }
예제 #13
0
        //private static String STATIS_YEAR_CATEGORY_STR = @"SELECT IFNULL(Sum(work), 0) works, IFNULL(Sum(expense),0) expenses FROM `workload` w, `item` i WHERE w.itemid = i.id AND i.projectid = @ProjectId";
        public static ContractWorkload StatisYearCategoryWorkLoad(int year, ContractCategory category)
        {
            MySqlConnection con = DBTools.GetMySqlConnection();
            MySqlCommand    cmd;

            ContractWorkload workload = null;

            try
            {
                con.Open();

                cmd = con.CreateCommand();

                cmd.CommandText = STATIS_DEPARTMENT_YEAR_CATEGORY_STR;
                cmd.Parameters.AddWithValue("@SDepartmentYear", "__" + year + "%");
                cmd.Parameters.AddWithValue("@CategoryId", category.Id);
                MySqlDataReader sqlRead = cmd.ExecuteReader();

                cmd.Dispose();

                while (sqlRead.Read())
                {
                    workload = new ContractWorkload();

                    workload.ContractId = STATIS_KIND.STATIS_YEAR_CATEGORY_WORKLOAD.ToString();
                    workload.Work       = double.Parse(sqlRead["works"].ToString());
                    workload.Expense    = double.Parse(sqlRead["expenses"].ToString());

                    /// BUG
                    ContractItem item = new ContractItem();
                    item.Id       = -1;
                    workload.Item = item;
                }


                con.Close();
                con.Dispose();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (con.State == ConnectionState.Open)
                {
                    con.Close();
                }
            }
            return(workload);
        }
예제 #14
0
        public void pageInit_1(EnegAnalysis parent)
        {
            this.m_parent                = parent;
            this.pbLoading.Visible       = false;
            this.btndel.Enabled          = true;
            this.btnAdd.Enabled          = true;
            this.dtptime.Value           = System.DateTime.Now;
            this.m_dtbeginlast           = this.dtptime.Value;
            this.cboperiod.SelectedIndex = 0;
            this.m_oldcboperiodindex     = this.cboperiod.SelectedIndex;
            float cO2KG = Sys_Para.GetCO2KG();

            if (cO2KG < 0f)
            {
                this.txtco2_elec.Text = "";
            }
            else
            {
                this.txtco2_elec.Text = cO2KG.ToString("F2");
            }
            float eLECTRICITYCOST = Sys_Para.GetELECTRICITYCOST();

            if (eLECTRICITYCOST < 0f)
            {
                this.txtprice_elec.Text = "";
            }
            else
            {
                this.txtprice_elec.Text = eLECTRICITYCOST.ToString("F2");
            }
            float cO2COST = Sys_Para.GetCO2COST();

            if (eLECTRICITYCOST < 0f)
            {
                this.txtprice_co2.Text = "";
            }
            else
            {
                this.txtprice_co2.Text = cO2COST.ToString("F2");
            }
            this.label39.Text = EcoGlobalVar.CurCurrency + this.m_ElecUnit;
            this.label2.Text  = EcoGlobalVar.CurCurrency + this.m_CO2Unit;
            this.FillgroupList();
            if (!DBTools.DatabaseIsReady())
            {
                EcoMessageBox.ShowInfo(this, EcoLanguage.getMsg(LangRes.DB_waitready, new string[0]));
                this.btnGen.Enabled = false;
                return;
            }
            this.btnGen.Enabled = true;
        }
예제 #15
0
        /// <summary>
        ///  统计当前部门申请的所有工程Project下的会签单信息[Search数据填写SDepartmentShortCall + ItemId]
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        public static ContractWorkload StatisSDepartmentProjectYearWorkload(Search search)
        {
            MySqlConnection con = DBTools.GetMySqlConnection();
            MySqlCommand    cmd;

            ContractWorkload workload = null;

            try
            {
                con.Open();

                cmd = con.CreateCommand();

                cmd.CommandText = STATIS_SDEPARTMENT_PROJECT_YEAR_WORKLOAD_STR;
                cmd.Parameters.AddWithValue("@SDepartmentYear", search.SDepartmentShortlCall + "_" + search.Year.ToString() + "%");
                cmd.Parameters.AddWithValue("@ProjectId", search.ProjectId);
                MySqlDataReader sqlRead = cmd.ExecuteReader();

                cmd.Dispose();

                while (sqlRead.Read())
                {
                    workload = new ContractWorkload();

                    workload.ContractId = "STATIS";

                    workload.Work    = -1;
                    workload.Expense = double.Parse(sqlRead["expenses"].ToString());

                    ContractItem item = new ContractItem();
                    item.Id       = -1;
                    workload.Item = item;
                }


                con.Close();
                con.Dispose();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (con.State == ConnectionState.Open)
                {
                    con.Close();
                }
            }
            return(workload);
        }
예제 #16
0
        public static List <SignatureDetail> QuerySignatureDetail(int empid)
        {
            MySqlConnection con = DBTools.GetMySqlConnection( );
            MySqlCommand    cmd;

            List <SignatureDetail> details = new List <SignatureDetail>();

            try
            {
                con.Open();

                cmd = con.CreateCommand();

                cmd.CommandText = QUERY_SIGNATURE_DETAIL_EMP_STR;
                cmd.Parameters.AddWithValue("@empid", empid);


                MySqlDataReader sqlRead = cmd.ExecuteReader();
                cmd.Dispose();

                while (sqlRead.Read())
                {
                    SignatureDetail detail = new SignatureDetail();

                    // detail.Id = sqlRead["id"].ToString();
                    detail.Date   = sqlRead["date"].ToString();
                    detail.EmpId  = int.Parse(sqlRead["empid"].ToString());
                    detail.ConId  = sqlRead["conid"].ToString();
                    detail.Result = int.Parse(sqlRead["result"].ToString());
                    detail.Remark = sqlRead["remark"].ToString();

                    details.Add(detail);
                }


                con.Close();
                con.Dispose();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (con.State == ConnectionState.Open)
                {
                    con.Close();
                }
            }
            return(details);
        }
예제 #17
0
        public static List <SHDJContract> QuerySignatureStatusRefuse(int employeeId)
        {
            MySqlConnection con = DBTools.GetMySqlConnection();
            MySqlCommand    cmd;

            List <SHDJContract> contracts = new List <SHDJContract>();

            try
            {
                con.Open();

                cmd = con.CreateCommand();

                cmd.CommandText = QUERY_SIGNATURE_STATUS_REFUSE_EMP_STR;
                cmd.Parameters.AddWithValue("@EmployeeId", employeeId);

                MySqlDataReader sqlRead = cmd.ExecuteReader();
                cmd.Dispose();

                while (sqlRead.Read())
                {
                    SHDJContract contract = new SHDJContract();
                    contract.Id         = sqlRead["id"].ToString();
                    contract.Name       = sqlRead["name"].ToString();
                    contract.SubmitDate = sqlRead["submitdate"].ToString();

                    contract.ProjectName = sqlRead["columndata1"].ToString();

                    contract.CurrLevel = int.Parse(sqlRead["currlevel"].ToString());
                    contract.MaxLevel  = int.Parse(sqlRead["maxlevel"].ToString());

                    contracts.Add(contract);
                }


                con.Close();
                con.Dispose();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (con.State == ConnectionState.Open)
                {
                    con.Close();
                }
            }
            return(contracts);
        }
예제 #18
0
        /// <summary>
        ///  统计当前部门申请的所有工程Project下的会签单信息[Search数据填写SDepartmentShortCall + ItemId]
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        public static ContractWorkload StatisDepartmentYearProjectWorkLoad(HSDepartment department, int year, ContractProject project)
        {
            MySqlConnection con = DBTools.GetMySqlConnection();
            MySqlCommand    cmd;

            ContractWorkload workload = null;

            try
            {
                con.Open();

                cmd = con.CreateCommand();

                cmd.CommandText = STATIS_DEPARTMENT_YEAR_PROJECT_STR;
                cmd.Parameters.AddWithValue("@SDepartmentYear", department.ShortCall + "_" + year.ToString() + "%");
                cmd.Parameters.AddWithValue("@ProjectId", project.Id);
                MySqlDataReader sqlRead = cmd.ExecuteReader();

                cmd.Dispose();

                while (sqlRead.Read())
                {
                    workload = new ContractWorkload();

                    workload.ContractId = STATIS_KIND.STATIS_DEPARTMENT_YEAR_PROJECT_WORKLOAD.ToString();

                    workload.Work    = double.Parse(sqlRead["works"].ToString());
                    workload.Expense = double.Parse(sqlRead["expenses"].ToString());

                    ContractItem item = new ContractItem();
                    item.Id       = -1;
                    workload.Item = item;
                }


                con.Close();
                con.Dispose();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (con.State == ConnectionState.Open)
                {
                    con.Close();
                }
            }
            return(workload);
        }
예제 #19
0
        public static List <SDepartment> QuerySDepartment()
        {
            MySqlConnection con = DBTools.GetMySqlConnection();
            MySqlCommand    cmd;

            List <SDepartment> departments = new List <SDepartment>();

            try
            {
                con.Open();

                cmd = con.CreateCommand();

                cmd.CommandText = QUERY_SDEPARTMENT_STR;

                MySqlDataReader sqlRead = cmd.ExecuteReader();
                cmd.Dispose();

                while (sqlRead.Read())
                {
                    SDepartment department = new SDepartment();

                    department.Id        = int.Parse(sqlRead["id"].ToString());
                    department.Name      = sqlRead["name"].ToString();
                    department.ShortCall = sqlRead["shortcall"].ToString();

                    department.CanBoundary = int.Parse(sqlRead["canboundary"].ToString());
                    department.CanInland   = int.Parse(sqlRead["caninland"].ToString());


                    departments.Add(department);
                }


                con.Close();
                con.Dispose();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (con.State == ConnectionState.Open)
                {
                    con.Close();
                }
            }
            return(departments);
        }
예제 #20
0
 private void btnXoa_Click(object sender, EventArgs e)
 {
     if (IdKiemKe != 0)
     {
         GtidCommand sqlcmd = new GtidCommand();
         sqlcmd.CommandType = CommandType.StoredProcedure;
         sqlcmd.CommandText = "sp_KiemKe_Delete";
         sqlcmd.Parameters.AddWithValue("@IdKiemKe", IdKiemKe);
         if (!DBTools.DeleteRecord(sqlcmd))
         {
             throw DBTools._LastError;
         }
     }
 }
예제 #21
0
        public static DataTable DBGetRekonHI(Guid ownPtRowID, string ownCabangID, Guid perusahaanRowID, string cabangID, DateTime?fromDate, DateTime?toDate)
        {
            DataTable        dt  = null;
            List <Parameter> prm = new List <Parameter>();

            prm.Add(new Parameter("@OwnPtRowID", SqlDbType.UniqueIdentifier, ownPtRowID));
            prm.Add(new Parameter("@OwnCabangID", SqlDbType.VarChar, ownCabangID));
            prm.Add(new Parameter("@PerusahaanRowID", SqlDbType.UniqueIdentifier, perusahaanRowID));
            prm.Add(new Parameter("@CabangID", SqlDbType.VarChar, cabangID));
            prm.Add(new Parameter("@fromDate", SqlDbType.Date, fromDate));
            prm.Add(new Parameter("@toDate", SqlDbType.Date, toDate));
            dt = DBTools.DBGetDataTable("rsp_RekonsiliasiHI", prm);
            return(dt);
        }
예제 #22
0
        /// <summary>
        /// 修改工作量信息
        /// </summary>
        /// <param name="workload"></param>
        /// <returns></returns>
        public static bool ModifyWorkload(ContractWorkload workload)
        {
            MySqlConnection con = DBTools.GetMySqlConnection();
            MySqlCommand    cmd;
            int             count = -1;

            try
            {
                con.Open();

                cmd = con.CreateCommand();

                cmd.CommandText = MODIFY_WORKLOAD_STR;
                cmd.Parameters.AddWithValue("@ContractId", workload.ContractId);
                cmd.Parameters.AddWithValue("@ItemId", workload.Item.Id);
                cmd.Parameters.AddWithValue("@Work", workload.Work);
                cmd.Parameters.AddWithValue("@WorkInfo", workload.WorkInfo);
                cmd.Parameters.AddWithValue("@Expense", workload.Expense);


                count = cmd.ExecuteNonQuery();
                cmd.Dispose();

                con.Close();
                con.Dispose();

                if (count == 1)
                {
                    Console.WriteLine("修改工作量[表" + workload.ContractId.ToString() + ", " + workload.Item.Id + "成功");
                    return(true);
                }
                else
                {
                    Console.WriteLine("修改工作量[表" + workload.ContractId.ToString() + ", " + workload.Item.Id + "失败");

                    return(false);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (con.State == ConnectionState.Open)
                {
                    con.Close();
                }
            }
        }
예제 #23
0
        private void LoadComboLoaiSanPham()
        {
            string    sql = "SELECT IdSanPham, TenSanPham FROM tbl_SanPham WHERE IdCha is null and SuDung=1 ORDER BY TenSanPham";
            DataTable dt  = DBTools.getData("Temp", sql).Tables["Temp"];
            DataRow   dr  = dt.NewRow();

            dr["IdSanPham"]  = 0;
            dr["TenSanPham"] = String.Empty;
            dt.Rows.InsertAt(dr, 0);
            cboLoaiSP.DisplayMember = "TenSanPham";
            cboLoaiSP.ValueMember   = "IdSanPham";
            cboLoaiSP.DataSource    = dt;
            cboLoaiSP.Refresh();
        }
        private void cboPhieuXuat_SelectedIndexChanged(object sender, EventArgs e)
        {
            double IdPX = Convert.ToDouble(cboPhieuXuat.SelectedValue);
            string str  = "select ct.IdChungTu,ct.SoSeri,ct.NgayLap,ct.HoTen " +
                          "from tbl_ChungTu ct " +
                          "where IdChungTu=" + IdPX;
            DataTable dt = DBTools.getData("Tmp", str).Tables["Tmp"];

            if (dt != null && dt.Rows.Count > 0)
            {
                this.txtKhachHang.Text = dt.Rows[0]["HoTen"].ToString();
                this.dtNgayBan.Value   = (DateTime)dt.Rows[0]["NgayLap"];
            }
        }
예제 #25
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            Utils ut = new Utils();

            foreach (DataGridViewRow r in dgvList.Rows)
            {
                if (ut.getBool(r.Cells["Chon"].Value) == true)
                {
                    string sql = String.Format("Delete from tbl_Nhatky_Dongbo_ERP where IdNhatKy={0}", r.Cells["IdNhatKy"].Value);
                    DBTools.ExecuteQuery(sql, CommandType.Text);
                }
            }
            btnFilter_Click(this, null);
        }
예제 #26
0
        // 通过user_id 编辑用户
        public void updateUser(User user)
        {
            string sql = "update TB_user set user_name = '" + user.user_name +
                         "', user_password = '******', user_age = '" + user.user_age +
                         "', user_gender = '" + user.user_gender +
                         "', user_info = '" + user.user_info +
                         "', user_phone = '" + user.user_phone +
                         "' where user_id = '" + user.user_id + "'";

            SqlCommand sc = DBTools.getSqlCommand(sql);

            sc.ExecuteNonQuery();
        }
예제 #27
0
        public void addMyFileInfo(MyFileInfo myFileInfo)
        {
            // 新增数据的sql
            sql = "insert into TB_files values ('" + myFileInfo.seq
                  + "', '" + myFileInfo.file_name
                  + "', '" + myFileInfo.file_parent_name
                  + "', '" + myFileInfo.create_date
                  + "')";

            SqlCommand sc = DBTools.getSqlCommand(sql);

            sc = DBTools.getSqlCommand(sql);
            sc.ExecuteNonQuery();
        }
예제 #28
0
        private void LoadHinhThucTra()
        {
            string str = "Select IdThuChi, KyHieu + ' - ' + Ten ThuChi From tbl_DM_LoaiThuChi " +
                         " Where SuDung=1 order by KyHieu ";

            DataTable dt = DBTools.getData("tmp", str).Tables["tmp"];

            if (dt != null)
            {
                this.cboHinhThucTra.DataSource    = dt;
                this.cboHinhThucTra.DisplayMember = "ThuChi";
                this.cboHinhThucTra.ValueMember   = "IdThuChi";
            }
        }
예제 #29
0
        public void addApply(Apply apply)
        {
            // 新增数据的sql
            sql = "insert into TB_apply values ('" + apply.apply_id
                  + "', '" + apply.apply_title
                  + "', '" + apply.apply_info
                  + "', '" + apply.apply_create_date
                  + "')";

            SqlCommand sc = DBTools.getSqlCommand(sql);

            sc = DBTools.getSqlCommand(sql);
            sc.ExecuteNonQuery();
        }
예제 #30
0
        private void CapNhatTheBaoHanh()
        {
            try
            {
                oDataSource.IdChungTu   = ChungTu.IdChungTu;
                oDataSource.SoPhieuXuat = txtSoPhieu.Text.ToUpper().Trim();
                oDataSource.TenDoiTuong = txtHoTen.Text.Trim();
                oDataSource.DienThoai   = txtDienThoai.Text.Trim();
                oDataSource.MaRieng     = txtMaKH.Text.Trim();
                oDataSource.DiaChi      = txtDiaChi.Text.Trim();

                foreach (InPhieuBaoHanhChiTietInfor pt in lstBaoHanh)
                {
                    GtidCommand sqlcmd = null;
                    sqlcmd = ConnectionUtil.Instance.GetConnection().CreateCommand();
                    ConnectionUtil.Instance.BeginTransaction();

                    sqlcmd.CommandType = CommandType.StoredProcedure;
                    sqlcmd.CommandText = "sp_BaoHanh_Insert";

                    int    idPhieuXuat = oDataSource != null ? oDataSource.IdChungTu : 0;
                    string ghichu      = "Số phiếu BH: " + txtSoPhieu.Text;
                    ghichu += "\r\n Khách hàng: " + txtHoTen.Text;
                    ghichu += "\r\n Nơi mua hàng: " + pt.NoiMua;

                    sqlcmd.Parameters.Clear();
                    sqlcmd.Parameters.AddWithValue("@IdBaoHanh", 0).Direction             = ParameterDirection.Output;
                    sqlcmd.Parameters.AddWithValue("@SerialNumber", pt.MaVach).Direction  = ParameterDirection.Input;
                    sqlcmd.Parameters.AddWithValue("@IdPhieuXuat", idPhieuXuat).Direction = ParameterDirection.Input;
                    sqlcmd.Parameters.AddWithValue("@NgayBatDau", pt.NgayMua).Direction   = ParameterDirection.Input;
                    sqlcmd.Parameters.AddWithValue("@NgayKetThuc", pt.DenNgay).Direction  = ParameterDirection.Input;
                    sqlcmd.Parameters.AddWithValue("@GhiChu", ghichu).Direction           = ParameterDirection.Input;

                    DBTools.InsertRecord(sqlcmd);

                    ConnectionUtil.Instance.CommitTransaction();
                    Common.LogAction("Cập nhật phiếu bảo hành", "Số phiếu bảo hành = " + txtSoPhieu.Text, Declare.IdKho);
                }
            }
            catch (System.Exception ex)
            {
                ConnectionUtil.Instance.RollbackTransaction();
#if DEBUG
                //MessageBox.Show("Lỗi ngoại lệ: " + ex.ToString(), Declare.titleError, MessageBoxButtons.OK, MessageBoxIcon.Error);
#else
                //MessageBox.Show("Lỗi ngoại lệ: " + ex.Message, Declare.titleError, MessageBoxButtons.OK, MessageBoxIcon.Error);
#endif
            }
            //return -1;
        }