예제 #1
0
 /// <summary>
 /// 将数据保存到数据库
 /// </summary>
 /// <param name="dataSet1"></param>
 public static void SaveBussinessCategory(DataSet dataSet1)
 {
     using (SqlConnection conn = new SqlConnection(BaseSQL.connectionString))
     {
         conn.Open();
         using (SqlTransaction trans = conn.BeginTransaction())
         {
             try
             {
                 SqlCommand cmd = new SqlCommand("", conn, trans);
                 cmd.CommandText = "select Top 0 * from BS_BussinessCategory ";
                 SqlDataAdapter adp = new SqlDataAdapter(cmd);
                 DataTable      dt  = new DataTable();
                 adp.Fill(dt);
                 BaseSQL.UpdateDataTable(adp, dataSet1.Tables["BussinessCategory"]);
                 trans.Commit();
             }
             catch (System.Data.SqlClient.SqlException)
             {
                 MessageBox.Show("当前往来类别编码已经被使用,不能修改!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 trans.Rollback();
                 dataSet1.Tables["BussinessCategory"].RejectChanges();
             }
             catch (Exception ex)
             {
                 trans.Rollback();
                 dataSet1.Tables["BussinessCategory"].RejectChanges();
                 throw ex;
             }
         }
     }
 }
예제 #2
0
        /// <summary>
        /// 保存导入的物料信息
        /// </summary>
        public void SaveImportPartsCode(DataTable partsCodeTable)
        {
            using (SqlConnection conn = new SqlConnection(BaseSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        SqlCommand cmd = new SqlCommand("", conn, trans);

                        cmd.CommandText = "select * from SW_PartsCode where 1=2";
                        SqlDataAdapter adapterList = new SqlDataAdapter(cmd);
                        DataTable      tmpPCTable  = new DataTable();
                        adapterList.Fill(tmpPCTable);
                        BaseSQL.UpdateDataTable(adapterList, partsCodeTable);

                        trans.Commit();
                    }
                    catch (Exception ex)
                    {
                        trans.Rollback();
                        throw ex;
                    }
                    finally
                    {
                        conn.Close();
                    }
                }
            }
        }
예제 #3
0
        /// <summary>
        /// 保存系统参数表
        /// </summary>
        public bool SaveSystemParameter(DataTable queryDataTable)
        {
            using (SqlConnection conn = new SqlConnection(BaseSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        SqlCommand cmd = new SqlCommand("", conn, trans);

                        cmd.CommandText = "select * from BS_SysParameter where 1=2";
                        SqlDataAdapter adapterHead  = new SqlDataAdapter(cmd);
                        DataTable      tmpHeadTable = new DataTable();
                        adapterHead.Fill(tmpHeadTable);
                        BaseSQL.UpdateDataTable(adapterHead, queryDataTable);

                        cmd.CommandText = "update BS_DataCurrentNode set isEnd = 1";

                        trans.Commit();
                        return(true);
                    }
                    catch (Exception ex)
                    {
                        trans.Rollback();
                        queryDataTable.RejectChanges();
                        throw ex;
                    }
                    finally
                    {
                        conn.Close();
                    }
                }
            }
        }
예제 #4
0
        /// <summary>
        /// 保存付款类型信息
        /// </summary>
        public bool SaveCollectionTypeList(DataTable updateDataTable, string collectionTypeNoStr)
        {
            using (SqlConnection conn = new SqlConnection(BaseSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        SqlCommand cmd = new SqlCommand("", conn, trans);

                        cmd.CommandText = "select * from BS_CollectionTypeList where 1=2";
                        SqlDataAdapter adapterHead  = new SqlDataAdapter(cmd);
                        DataTable      tmpHeadTable = new DataTable();
                        adapterHead.Fill(tmpHeadTable);
                        BaseSQL.UpdateDataTable(adapterHead, updateDataTable);

                        //cmd.CommandText = string.Format("select * from PUR_PayTypeList where PayTypeNo='{0}'", payTypeNoStr);
                        //adapterHead = new SqlDataAdapter(cmd);
                        //tmpHeadTable.Rows.Clear();
                        //adapterHead.Fill(tmpHeadTable);

                        cmd.CommandText = string.Format("select Sum(CollectionPercentum) from BS_CollectionTypeList where CollectionTypeNo='{0}'", collectionTypeNoStr);
                        int sumInt = DataTypeConvert.GetInt(cmd.ExecuteScalar());
                        if (sumInt != 100)
                        {
                            trans.Rollback();
                            //MessageHandler.ShowMessageBox("收款百分比的合计必须是100,请刷新后再重新操作。");
                            MessageHandler.ShowMessageBox(f.tsmiSkbfbd.Text);
                            return(false);
                        }

                        //保存日志到日志表中
                        //string logStr = "对[收款类型信息]表进行[修改]操作:";
                        string logStr = f.tsmiDsklxx.Text;
                        for (int i = 0; i < updateDataTable.Rows.Count; i++)
                        {
                            //logStr += string.Format("主键的值为[{0}]百分比的值为[{1}]说明的值为[{2}];", updateDataTable.Rows[i]["AutoId"].ToString(), updateDataTable.Rows[i]["CollectionPercentum"].ToString(), updateDataTable.Rows[i]["CollectionPercentumText"].ToString());
                            logStr += string.Format(f.tsmiZjdzw.Text + "[{0}]" + f.tsmiBfbdzw.Text + "[{1}]" + f.tsmiSmdzw.Text + "[{2}];", updateDataTable.Rows[i]["AutoId"].ToString(), updateDataTable.Rows[i]["CollectionPercentum"].ToString(), updateDataTable.Rows[i]["CollectionPercentumText"].ToString());
                        }

                        LogHandler.RecordLog(cmd, logStr);

                        trans.Commit();
                        return(true);
                    }
                    catch (Exception ex)
                    {
                        trans.Rollback();
                        throw ex;
                    }
                    finally
                    {
                        conn.Close();
                    }
                }
            }
        }
예제 #5
0
        /// <summary>
        /// 保存公司信息表
        /// </summary>
        public bool SaveCompanyInfo(DataRow headRow)
        {
            using (SqlConnection conn = new SqlConnection(BaseSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        SqlCommand cmd = new SqlCommand("", conn, trans);

                        string logStr = LogHandler.RecordLog_DataRow(cmd, "公司信息", headRow, "AutoId");

                        cmd.CommandText = "select * from BS_CompanyInfo";
                        DataTable companyInfoTable = BaseSQL.GetTableBySql(cmd);
                        if (companyInfoTable.Rows.Count > 0)
                        {
                            if (headRow.RowState == DataRowState.Modified && DataTypeConvert.GetString(companyInfoTable.Rows[0]["AutoId"]) != DataTypeConvert.GetString(headRow["AutoId"]))
                            {
                                string CompanyName    = DataTypeConvert.GetString(headRow["CompanyName"]);
                                string CompanyAddress = DataTypeConvert.GetString(headRow["CompanyAddress"]);
                                string CompanyLR      = DataTypeConvert.GetString(headRow["CompanyLR"]);
                                string CompanyLicense = DataTypeConvert.GetString(headRow["CompanyLicense"]);
                                string ZipCode        = DataTypeConvert.GetString(headRow["ZipCode"]);
                                string PhoneNo        = DataTypeConvert.GetString(headRow["PhoneNo"]);
                                string FaxNo          = DataTypeConvert.GetString(headRow["FaxNo"]);
                                string E_mail         = DataTypeConvert.GetString(headRow["E_mail"]);
                                string WebSite        = DataTypeConvert.GetString(headRow["WebSite"]);

                                cmd.CommandText = string.Format("Update BS_CompanyInfo set CompanyName = '{1}', CompanyAddress = '{2}', CompanyLR = '{3}', CompanyLicense = '{4}', ZipCode = '{5}', PhoneNo = '{6}', FaxNo = '{7}', E_mail = '{8}', WebSite = '{9}' where AutoId = '{0}'", DataTypeConvert.GetString(companyInfoTable.Rows[0]["AutoId"]), CompanyName, CompanyAddress, CompanyLR, CompanyLicense, ZipCode, PhoneNo, FaxNo, E_mail, WebSite);
                                cmd.ExecuteNonQuery();
                                trans.Commit();
                                return(true);
                            }
                        }

                        cmd.CommandText = "select * from BS_CompanyInfo where 1=2";
                        SqlDataAdapter adapterHead  = new SqlDataAdapter(cmd);
                        DataTable      tmpHeadTable = new DataTable();
                        adapterHead.Fill(tmpHeadTable);
                        BaseSQL.UpdateDataTable(adapterHead, headRow.Table);

                        trans.Commit();
                        return(true);
                    }
                    catch (Exception ex)
                    {
                        trans.Rollback();
                        headRow.Table.RejectChanges();
                        throw ex;
                    }
                    finally
                    {
                        conn.Close();
                    }
                }
            }
        }
예제 #6
0
        /// <summary>
        /// 将数据保存到数据库
        /// </summary>
        /// <param name="dataSet1"></param>
        public static void SaveBussinessBaseInfo(DataSet dataSet1)
        {
            using (SqlConnection conn = new SqlConnection(BaseSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        SqlCommand cmd = new SqlCommand("", conn, trans);
                        cmd.CommandText = "select Top 0 * from BS_BussinessBaseInfo ";
                        SqlDataAdapter adp = new SqlDataAdapter(cmd);
                        DataTable      dt  = new DataTable();
                        adp.Fill(dt);
                        BaseSQL.UpdateDataTable(adp, dataSet1.Tables["BussinessBaseInfo"]);

                        cmd.CommandText = "select Top 0 * from BS_BussinessDetailInfo ";
                        SqlDataAdapter adp1 = new SqlDataAdapter(cmd);
                        DataTable      dt1  = new DataTable();
                        adp1.Fill(dt1);
                        BaseSQL.UpdateDataTable(adp1, dataSet1.Tables[1]);

                        cmd.CommandText = "select Top 0 * from BS_BussinessFinancialInfo ";
                        SqlDataAdapter adp2 = new SqlDataAdapter(cmd);
                        DataTable      dt2  = new DataTable();
                        adp2.Fill(dt2);
                        BaseSQL.UpdateDataTable(adp2, dataSet1.Tables["BussinessFinancialInfo"]);
                        trans.Commit();
                    }
                    catch (System.Data.SqlClient.SqlException)
                    {
                        MessageHandler.ShowMessageBox("当前往来方编码已经被使用,不能修改!");
                        trans.Rollback();
                        dataSet1.Tables["BussinessDetailInfo"].RejectChanges();
                        dataSet1.Tables["BussinessFinancialInfo"].RejectChanges();
                        dataSet1.Tables["BussinessBaseInfo"].RejectChanges();
                    }
                    catch (System.Data.DBConcurrencyException)
                    {
                        MessageHandler.ShowMessageBox("当前往来方编码已经被使用,不能修改1111!");
                        trans.Rollback();
                        dataSet1.Tables["BussinessDetailInfo"].RejectChanges();
                        dataSet1.Tables["BussinessFinancialInfo"].RejectChanges();
                        dataSet1.Tables["BussinessBaseInfo"].RejectChanges();
                    }

                    catch (Exception ex)
                    {
                        trans.Rollback();
                        dataSet1.Tables["BussinessDetailInfo"].RejectChanges();
                        dataSet1.Tables["BussinessFinancialInfo"].RejectChanges();
                        dataSet1.Tables["BussinessBaseInfo"].RejectChanges();
                        throw ex;
                    }
                }
            }
        }
예제 #7
0
        /// <summary>
        /// 菜单下移
        /// </summary>
        public static void MenuDownMove(string menuNameStr, string parentMenuNameStr)
        {
            using (SqlConnection conn = new SqlConnection(BaseSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        SqlCommand cmd = new SqlCommand("", conn, trans);
                        cmd.CommandText = string.Format("select * from BS_Menu where IsNull(ParentMenuName, '')='{0}' order by MenuOrder", parentMenuNameStr);
                        SqlDataAdapter adapterHead = new SqlDataAdapter(cmd);
                        DataTable      menuTable   = new DataTable();
                        adapterHead.Fill(menuTable);

                        for (int i = 0; i < menuTable.Rows.Count; i++)
                        {
                            menuTable.Rows[i]["MenuOrder"] = i;
                        }
                        DataRow[] drs = menuTable.Select(string.Format("MenuName = '{0}'", menuNameStr));
                        if (drs.Length > 0)
                        {
                            int orderInt = DataTypeConvert.GetInt(drs[0]["MenuOrder"]);
                            if (orderInt < menuTable.Rows.Count - 1)
                            {
                                menuTable.Select(string.Format("MenuOrder = {0}", orderInt + 1))[0]["MenuOrder"] = orderInt;
                                drs[0]["MenuOrder"] = orderInt + 1;
                            }
                        }

                        BaseSQL.UpdateDataTable(adapterHead, menuTable);

                        trans.Commit();
                    }
                    catch (Exception ex)
                    {
                        trans.Rollback();
                        throw ex;
                    }
                    finally
                    {
                        conn.Close();
                    }
                }
            }
        }
예제 #8
0
        /// <summary>
        /// 更新往来方其他信息
        /// </summary>
        public void Update_BussinessOtherInfo(SqlCommand cmd, DataTable detailInfoTable, DataTable FinancialInfoTable)
        {
            DataRowState drs = detailInfoTable.Rows[0].RowState;

            cmd.CommandText = "select * from BS_BussinessDetailInfo where 1=2";
            SqlDataAdapter adapterHead  = new SqlDataAdapter(cmd);
            DataTable      tmpHeadTable = new DataTable();

            adapterHead.Fill(tmpHeadTable);
            BaseSQL.UpdateDataTable(adapterHead, detailInfoTable);

            cmd.CommandText = "select * from BS_BussinessFinancialInfo where 1=2";
            SqlDataAdapter adapterList  = new SqlDataAdapter(cmd);
            DataTable      tmpListTable = new DataTable();

            adapterList.Fill(tmpListTable);
            BaseSQL.UpdateDataTable(adapterList, FinancialInfoTable);
        }
예제 #9
0
        /// <summary>
        /// 保存Bom登记信息
        /// </summary>
        public int SaveBomManagement(DataRow bomHeadRow, DataTable bomListTable)
        {
            using (SqlConnection conn = new SqlConnection(BaseSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        SqlCommand cmd = new SqlCommand("", conn, trans);

                        DateTime nowTime = BaseSQL.GetServerDateTime();
                        if (bomHeadRow.RowState == DataRowState.Added)//新增
                        {
                            cmd.CommandText = string.Format("select COUNT(*) from BS_BomManagement where MaterielNo = '{0}'", DataTypeConvert.GetString(bomHeadRow["MaterielNo"]));
                            if (DataTypeConvert.GetInt(cmd.ExecuteScalar()) > 0)
                            {
                                //MessageHandler.ShowMessageBox("当前选择的零件名称已经存在Bom信息,不能重复设定,请重新输入。");
                                MessageHandler.ShowMessageBox(f.tsmiDqxzdl.Text);

                                trans.Rollback();
                                return(0);
                            }

                            bomHeadRow["GetTime"] = nowTime;
                            for (int i = 0; i < bomListTable.Rows.Count; i++)
                            {
                                bomListTable.Rows[i]["MaterielNo"] = bomHeadRow["MaterielNo"];
                                bomListTable.Rows[i]["GetTime"]    = nowTime;
                            }
                        }
                        else//修改
                        {
                            for (int i = 0; i < bomListTable.Rows.Count; i++)
                            {
                                if (bomListTable.Rows[i].RowState == DataRowState.Deleted)
                                {
                                    continue;
                                }
                                else if (bomListTable.Rows[i].RowState == DataRowState.Added)
                                {
                                    bomListTable.Rows[i]["MaterielNo"] = bomHeadRow["MaterielNo"];
                                    bomListTable.Rows[i]["GetTime"]    = nowTime;
                                }
                            }
                        }

                        //保存日志到日志表中
                        //string logStr = LogHandler.RecordLog_DataRow(cmd, "Bom登记信息", bomHeadRow, "MaterielNo");
                        string logStr = LogHandler.RecordLog_DataRow(cmd, f.tsmiBomdjx.Text, bomHeadRow, "MaterielNo");

                        cmd.CommandText = "select * from BS_BomManagement where 1=2";
                        SqlDataAdapter adapterHead  = new SqlDataAdapter(cmd);
                        DataTable      tmpHeadTable = new DataTable();
                        adapterHead.Fill(tmpHeadTable);
                        BaseSQL.UpdateDataTable(adapterHead, bomHeadRow.Table);

                        cmd.CommandText = "select * from BS_BomMateriel where 1=2";
                        SqlDataAdapter adapterList  = new SqlDataAdapter(cmd);
                        DataTable      tmpListTable = new DataTable();
                        adapterList.Fill(tmpListTable);
                        BaseSQL.UpdateDataTable(adapterList, bomListTable);

                        trans.Commit();

                        return(1);
                    }
                    catch (Exception ex)
                    {
                        trans.Rollback();
                        bomHeadRow.Table.RejectChanges();
                        bomListTable.RejectChanges();
                        throw ex;
                    }
                    finally
                    {
                        conn.Close();
                    }
                }
            }
        }