Exemplo n.º 1
0
        /// <summary>
        /// 保存多条生产计划Bom信息
        /// </summary>
        public bool SaveMultiProductionScheduleBom(List <int> bomListAutoIdList, int isAll, DateTime planDate, double remainQty)
        {
            using (SqlConnection conn = new SqlConnection(BaseSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        SqlCommand cmd = new SqlCommand("", conn, trans);

                        int    resultInt = 0;
                        string errorText = "";
                        foreach (int bomListAutoId in bomListAutoIdList)
                        {
                            string logStr = string.Format("保存生产计划Bom信息:[BomListAutoId]的值[{0}],[是否统一]的值[{1}],[需求日期]的值[{2}],[需求数量]的值[{3}]。", bomListAutoId, isAll, planDate.ToString("yyyy-MM-dd"), remainQty);
                            LogHandler.RecordLog(cmd, logStr);

                            SqlCommand   cmd_proc = new SqlCommand("", conn, trans);
                            SqlParameter p1       = new SqlParameter("@BomListAutoId", SqlDbType.Int);
                            p1.Value = bomListAutoId;
                            SqlParameter p2 = new SqlParameter("@AutoId", SqlDbType.Int);
                            p2.Value = 0;
                            SqlParameter p3 = new SqlParameter("@IsAll", SqlDbType.Int);
                            p3.Value = isAll;
                            SqlParameter p4 = new SqlParameter("@PlanDate", SqlDbType.DateTime);
                            p4.Value = planDate;
                            SqlParameter p5 = new SqlParameter("@RemainQty", SqlDbType.Float);
                            p5.Value = remainQty;
                            SqlParameter p6 = new SqlParameter("@IsBuy", SqlDbType.Int);
                            p6.Value = -1;
                            SqlParameter p7 = new SqlParameter("@Creator", SqlDbType.Int);
                            p7.Value = SystemInfo.user.AutoId;
                            SqlParameter p8 = new SqlParameter("@PreparedIp", SqlDbType.VarChar);
                            p8.Value = SystemInfo.HostIpAddress;
                            IDataParameter[] updateParas = new IDataParameter[] { p1, p2, p3, p4, p5, p6, p7, p8 };
                            BaseSQL.RunProcedure(cmd_proc, "P_PSBom_Insert", updateParas, out resultInt, out errorText);
                            if (resultInt != 1)
                            {
                                trans.Rollback();
                                MessageHandler.ShowMessageBox("保存生产计划Bom信息错误--" + errorText);
                                return(false);
                            }
                        }

                        trans.Commit();
                        return(true);
                    }
                    catch (Exception ex)
                    {
                        trans.Rollback();
                        throw ex;
                    }
                    finally
                    {
                        conn.Close();
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 更新生产计划单BOM信息
        /// </summary>
        public bool Update_ProductionScheduleBom(SqlCommand cmd, string psNoStr, out string errorText)
        {
            int          resultInt = 0;
            SqlParameter p1        = new SqlParameter("@PsNo", SqlDbType.VarChar);

            p1.Value = psNoStr;
            IDataParameter[] parameters = new System.Data.IDataParameter[] { p1 };
            return(BaseSQL.RunProcedure(cmd, "P_Update_ProductionScheduleBom", parameters, out resultInt, out errorText));
        }
Exemplo n.º 3
0
        public static void SaveRemarks(ListView lv, string remarks)
        {
            int newRemarksID;

            IDataParameter[] parameters = new System.Data.IDataParameter[4];  //实例化参数对象
            parameters[0]           = new SqlParameter("@Remarks", remarks);  //参数对象赋值
            parameters[1]           = new SqlParameter("@Founder", "songxi"); //需改成变量change
            parameters[2]           = new SqlParameter("@newRemarksID", SqlDbType.Int);
            parameters[3]           = new SqlParameter("@returnMessage", string.Empty);
            parameters[2].Direction = ParameterDirection.Output;
            parameters[3].Direction = ParameterDirection.Output;
            BaseSQL.RunProcedure("GetNewRemarksID", parameters);
            newRemarksID = Convert.ToInt32(parameters[2].Value);//

            FrmAddRemarksDAO.sqlLlist.Clear();
            foreach (ListViewItem lvi in lv.SelectedItems)
            {
                //项目或文档ID
                int itemID = Convert.ToInt32(lvi.Tag);
                try
                {
                    //如果是文件夹
                    if (lvi.SubItems[4].Text == "folder")
                    {
                        //获得项目列表
                        DataTable dt = FrmProjectDocumentDAO.GetAllLevelProjects(itemID);
                        //项目下的所有项目
                        foreach (DataRow dr in dt.Rows)
                        {
                            //调用保存【项目备注】方法
                            FrmAddRemarksDAO.SaveProjectsRemarks_AddSql(Convert.ToInt32(dr["projectID"]), newRemarksID);
                        }

                        //获得文件列表
                        dt = FrmProjectDocumentDAO.GetAllLevelDocuments(itemID);
                        //项目下的所有文件
                        foreach (DataRow dr in dt.Rows)
                        {
                            //调用保存【文档备注】方法
                            FrmAddRemarksDAO.SaveDocumentsRemarks_AddSql(Convert.ToInt32(dr["documentID"]), newRemarksID);
                        }
                    }
                    else//如果是文件
                    {
                        DataRow dr;
                        dr = FrmProjectDocumentDAO.GetDocumentInfo(itemID);
                        //调用保存【文档备注】方法
                        FrmAddRemarksDAO.SaveDocumentsRemarks_AddSql(Convert.ToInt32(dr["documentID"]), newRemarksID);
                    }
                    BaseSQL.ExecuteSqlTran(FrmAddRemarksDAO.sqlLlist);
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 生产计划新增Bom信息
        /// </summary>
        public void ProductionSchedule_InsertBom(string psNoStr, List <string> pbBomNoList, DateTime reqDate, decimal purQty)
        {
            if (pbBomNoList.Count == 0)
            {
                return;
            }

            using (SqlConnection conn = new SqlConnection(BaseSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        SqlCommand cmd = new SqlCommand("", conn, trans);

                        int    resultInt = 0;
                        string errorText = "";
                        foreach (string pbBomNoStr in pbBomNoList)
                        {
                            SqlCommand   cmd_proc = new SqlCommand("", conn, trans);
                            SqlParameter p1       = new SqlParameter("@PbBomNo", SqlDbType.VarChar);
                            p1.Value = pbBomNoStr;
                            SqlParameter p2 = new SqlParameter("@PsNo", SqlDbType.VarChar);
                            p2.Value = psNoStr;
                            SqlParameter p3 = new SqlParameter("@ReqDate", SqlDbType.DateTime);
                            p3.Value = reqDate;
                            SqlParameter p4 = new SqlParameter("@PurQty", SqlDbType.Float);
                            p4.Value = purQty;
                            IDataParameter[] updateParas = new IDataParameter[] { p1, p2, p3, p4 };
                            BaseSQL.RunProcedure(cmd_proc, "P_PSBom_Insert", updateParas, out resultInt, out errorText);
                            if (resultInt != 1)
                            {
                                trans.Rollback();
                                MessageHandler.ShowMessageBox("新增生产计划Bom信息错误--" + errorText);
                                return;
                            }

                            string logStr = string.Format("生产计划单[{0}]增加Bom零件信息[{1}],数量为[{2}]", psNoStr, pbBomNoStr, purQty);
                            LogHandler.RecordLog(cmd, logStr);
                        }
                        trans.Commit();
                    }
                    catch (Exception ex)
                    {
                        trans.Rollback();
                        throw ex;
                    }
                    finally
                    {
                        conn.Close();
                    }
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 更新当前的库存数
        /// </summary>
        public bool Update_WarehouseNowInfo(SqlCommand cmd, string warehouseNoStr, int HandleType, out string errorText)
        {
            int          resultInt = 0;
            SqlParameter p1        = new SqlParameter("@WarehouseNo", SqlDbType.VarChar);

            p1.Value = warehouseNoStr;
            SqlParameter p2 = new SqlParameter("@HandleType", SqlDbType.VarChar);

            p2.Value = HandleType;
            IDataParameter[] parameters = new System.Data.IDataParameter[] { p1, p2 };
            return(BaseSQL.RunProcedure(cmd, "P_Update_WarehouseNowInfo", parameters, out resultInt, out errorText));
        }
Exemplo n.º 6
0
        ///// <summary>
        ///// 生产计划更新Bom信息数量    新增和更新数量改为调用一个存储过程
        ///// </summary>
        //public void ProductionSchedule_UpdateBomQty(string psNoStr, List<string> pbBomNoList, decimal purQty)
        //{
        //    using (SqlConnection conn = new SqlConnection(BaseSQL.connectionString))
        //    {
        //        conn.Open();
        //        using (SqlTransaction trans = conn.BeginTransaction())
        //        {
        //            try
        //            {
        //                SqlCommand cmd = new SqlCommand("", conn, trans);

        //                int resultInt = 0;
        //                string errorText = "";
        //                foreach (string pbBomNoStr in pbBomNoList)
        //                {
        //                    SqlCommand cmd_proc = new SqlCommand("", conn, trans);
        //                    SqlParameter p1 = new SqlParameter("@PbBomNo", SqlDbType.VarChar);
        //                    p1.Value = pbBomNoStr;
        //                    SqlParameter p2 = new SqlParameter("@PsNo", SqlDbType.VarChar);
        //                    p2.Value = psNoStr;
        //                    SqlParameter p3 = new SqlParameter("@PurQty", SqlDbType.Float);
        //                    p3.Value = purQty;
        //                    IDataParameter[] updateParas = new IDataParameter[] { p1, p2, p3 };
        //                    BaseSQL.RunProcedure(cmd_proc, "P_PSBom_UpdateQty", updateParas, out resultInt, out errorText);
        //                    if (resultInt != 1)
        //                    {
        //                        trans.Rollback();
        //                        MessageHandler.ShowMessageBox("生产计划更新Bom信息数量错误--" + errorText);
        //                        return;
        //                    }
        //                }
        //                trans.Commit();

        //            }
        //            catch (Exception ex)
        //            {
        //                trans.Rollback();
        //                throw ex;
        //            }
        //            finally
        //            {
        //                conn.Close();
        //            }
        //        }
        //    }
        //}

        /// <summary>
        /// 删除生产计划Bom信息
        /// </summary>
        public bool ProductionSchedule_Delete(string psNoStr, List <string> pbBomNoList)
        {
            if (pbBomNoList.Count == 0)
            {
                return(false);
            }

            using (SqlConnection conn = new SqlConnection(BaseSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        SqlCommand cmd = new SqlCommand("", conn, trans);

                        int    resultInt = 0;
                        string errorText = "";
                        foreach (string pbBomNoStr in pbBomNoList)
                        {
                            SqlCommand   cmd_proc = new SqlCommand("", conn, trans);
                            SqlParameter p1       = new SqlParameter("@PbBomNo", SqlDbType.VarChar);
                            p1.Value = pbBomNoStr;
                            SqlParameter p2 = new SqlParameter("@PsNo", SqlDbType.VarChar);
                            p2.Value = psNoStr;
                            IDataParameter[] updateParas = new IDataParameter[] { p1, p2 };
                            BaseSQL.RunProcedure(cmd_proc, "P_PSBom_Delete", updateParas, out resultInt, out errorText);
                            if (resultInt != 1)
                            {
                                trans.Rollback();
                                MessageHandler.ShowMessageBox("删除生产计划Bom信息错误--" + errorText);
                                return(false);
                            }

                            string logStr = string.Format("生产计划单[{0}]删除Bom零件信息[{1}]", psNoStr, pbBomNoStr);
                            LogHandler.RecordLog(cmd, logStr);
                        }
                        trans.Commit();
                        return(true);
                    }
                    catch (Exception ex)
                    {
                        trans.Rollback();
                        throw ex;
                    }
                    finally
                    {
                        conn.Close();
                    }
                }
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// 在服务器创建文件夹
 /// </summary>
 /// <param name="projectName"></param>
 /// <param name="projectPath"></param>
 /// <param name="parentProjectID"></param>
 public static int CreateFolderToSever(string projectName, string projectPath, int parentProjectID)
 {
     //string sql;
     try
     {
         IDataParameter[] parameters = new System.Data.IDataParameter[5];         //实例化参数对象
         parameters[0]           = new SqlParameter("@projectName", projectName); //参数对象赋值
         parameters[1]           = new SqlParameter("@projectPath", projectPath);
         parameters[2]           = new SqlParameter("@parentProjectID", parentProjectID);
         parameters[3]           = new SqlParameter("@newProjectId", SqlDbType.Int);
         parameters[4]           = new SqlParameter("@returnMessage", string.Empty);
         parameters[3].Direction = ParameterDirection.Output;
         parameters[4].Direction = ParameterDirection.Output;
         BaseSQL.RunProcedure("CreateFolderToSever", parameters);
         return(Convert.ToInt32(parameters[3].Value));
     }
     catch (Exception ex)
     {
         ExceptionHandler.HandleException("在服务器创建文件夹错误。", ex);
         return(-1);
     }
 }
Exemplo n.º 8
0
 /// <summary>
 /// 在服务器创建文件夹
 /// </summary>
 /// <param name="projectName"></param>
 /// <param name="projectPath"></param>
 /// <param name="parentProjectID"></param>
 public static int CreateFolderToSever(string projectName, string projectPath, int parentProjectID)
 {
     //string sql;
     try
     {
         IDataParameter[] parameters = new System.Data.IDataParameter[5];         //实例化参数对象
         parameters[0]           = new SqlParameter("@projectName", projectName); //参数对象赋值
         parameters[1]           = new SqlParameter("@projectPath", projectPath);
         parameters[2]           = new SqlParameter("@parentProjectID", parentProjectID);
         parameters[3]           = new SqlParameter("@newProjectId", SqlDbType.Int);
         parameters[4]           = new SqlParameter("@returnMessage", string.Empty);
         parameters[3].Direction = ParameterDirection.Output;
         parameters[4].Direction = ParameterDirection.Output;
         BaseSQL.RunProcedure("CreateFolderToSever", parameters);
         return(Convert.ToInt32(parameters[3].Value));
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, f.tsmiTs.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
         return(-1);
     }
 }
Exemplo n.º 9
0
        /// <summary>
        /// 保存功能模块信息
        /// </summary>
        public int SaveStnModule(DataRow headRow, string copySMNoStr, int StnSummaryListModule_AutoIdInt)
        {
            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 (headRow.RowState == DataRowState.Added)//新增
                        {
                            headRow["SMNo"]       = BaseSQL.GetMaxCodeNo(cmd, "SM");
                            headRow["PreparedIp"] = SystemInfo.HostIpAddress;
                            headRow["GetTime"]    = nowTime;
                        }
                        else//修改
                        {
                        }

                        //保存日志到日志表中
                        string logStr = LogHandler.RecordLog_DataRow(cmd, "功能模块信息", headRow, "SMNo");

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

                        if (copySMNoStr != "")
                        {
                            if (StnSummaryListModule_AutoIdInt > 0)
                            {
                                cmd.CommandText = string.Format("Update SA_StnSummaryListModule set StnModuleId = '{1}' where AutoId = {0}", StnSummaryListModule_AutoIdInt, DataTypeConvert.GetString(headRow["SMNo"]));
                                cmd.ExecuteNonQuery();
                            }

                            int    resultInt = 0;
                            string errorText = "";

                            string smNoStr = DataTypeConvert.GetString(headRow["SMNo"]);

                            SqlCommand   cmd_proc = new SqlCommand("", conn, trans);
                            SqlParameter p1       = new SqlParameter("@CopySMNo", SqlDbType.VarChar);
                            p1.Value = copySMNoStr;
                            SqlParameter p2 = new SqlParameter("@NewSMNo", SqlDbType.VarChar);
                            p2.Value = smNoStr;
                            SqlParameter p3 = new SqlParameter("@Creator", SqlDbType.Int);
                            p3.Value = SystemInfo.user.AutoId;
                            SqlParameter p4 = new SqlParameter("@PreparedIp", SqlDbType.VarChar);
                            p4.Value = SystemInfo.HostIpAddress;
                            IDataParameter[] parameters = new IDataParameter[] { p1, p2, p3, p4 };
                            BaseSQL.RunProcedure(cmd_proc, "P_DeliveryDetail_Copy", parameters, out resultInt, out errorText);
                            if (resultInt != 1)
                            {
                                trans.Rollback();
                                MessageHandler.ShowMessageBox("复制供货明细信息错误--" + errorText);
                                return(-1);
                            }
                        }

                        trans.Commit();

                        return(1);
                    }
                    catch (Exception ex)
                    {
                        trans.Rollback();
                        headRow.Table.RejectChanges();
                        throw ex;
                    }
                    finally
                    {
                        conn.Close();
                    }
                }
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// 保存生产计划生成请购单
        /// </summary>
        public bool Save_PSBomToPrReq(string salesOrderNoStr, string pbBomNoStr, int bomListAutoIdInt, string projectNoStr, string stnNoStr, string departmentNoStr, string purCategoryStr, string approvalTypeStr)
        {
            using (SqlConnection conn = new SqlConnection(BaseSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        SqlCommand cmd = new SqlCommand("", conn, trans);

                        int    resultInt = 0;
                        string errorText = "";

                        string prReqNoStr = BaseSQL.GetMaxCodeNo(cmd, "PR");

                        SqlCommand   cmd_proc = new SqlCommand("", conn, trans);
                        SqlParameter p1       = new SqlParameter("@PbBomNo", SqlDbType.VarChar);
                        p1.Value = pbBomNoStr;
                        SqlParameter p2 = new SqlParameter("@BomListAutoId", SqlDbType.Int);
                        p2.Value = bomListAutoIdInt;
                        SqlParameter p3 = new SqlParameter("@PrReqNo", SqlDbType.VarChar);
                        p3.Value = prReqNoStr;
                        SqlParameter p4 = new SqlParameter("@ProjectNo", SqlDbType.VarChar);
                        p4.Value = projectNoStr;
                        SqlParameter p5 = new SqlParameter("@StnNo", SqlDbType.VarChar);
                        p5.Value = stnNoStr;

                        SqlParameter p6 = new SqlParameter("@DepartmentNo", SqlDbType.VarChar);
                        p6.Value = departmentNoStr;
                        SqlParameter p7 = new SqlParameter("@PurCategory", SqlDbType.VarChar);
                        p7.Value = purCategoryStr;
                        SqlParameter p8 = new SqlParameter("@ApprovalType", SqlDbType.VarChar);
                        p8.Value = approvalTypeStr;
                        SqlParameter p9 = new SqlParameter("@Creator", SqlDbType.Int);
                        p9.Value = SystemInfo.user.AutoId;
                        SqlParameter p10 = new SqlParameter("@PreparedIp", SqlDbType.VarChar);
                        p10.Value = SystemInfo.HostIpAddress;

                        IDataParameter[] parameters = new IDataParameter[] { p1, p2, p3, p4, p5, p6, p7, p8, p9, p10 };
                        BaseSQL.RunProcedure(cmd_proc, "P_PSBomToPrReq", parameters, out resultInt, out errorText);
                        if (resultInt != 1)
                        {
                            trans.Rollback();
                            MessageHandler.ShowMessageBox("生产计划生成请购单错误--" + errorText);
                            return(false);
                        }

                        string logStr = string.Format("制作Bom [{0}] 的生产计划生成请购单 [{1}]。", pbBomNoStr, prReqNoStr);
                        LogHandler.RecordLog(cmd, logStr);

                        trans.Commit();
                        return(true);
                    }
                    catch (Exception ex)
                    {
                        trans.Rollback();
                        throw ex;
                    }
                    finally
                    {
                        conn.Close();
                    }
                }
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// 更新生产计划单的Bom信息的需求日期
        /// </summary>
        public void ProductionSchedule_BomListReqDate(string psNoStr, List <int> autoIdList, DateTime reqDate)
        {
            if (autoIdList.Count == 0)
            {
                return;
            }

            using (SqlConnection conn = new SqlConnection(BaseSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        SqlCommand cmd = new SqlCommand("", conn, trans);

                        //方案一 只更新选中的一条记录
                        //string sqlStr = "";
                        //foreach (int autoId in autoIdList)
                        //{
                        //    sqlStr += string.Format(" {0},", autoId);
                        //}
                        //cmd.CommandText = string.Format("Update PB_ProductionScheduleBom set ReqDate = '{1}' where AutoId in ({0})", sqlStr.Substring(0, sqlStr.Length - 1), reqDate.ToString("yyyy-MM-dd"));
                        //cmd.ExecuteNonQuery();


                        //方案二 更新选中的记录和它下面的子节点
                        int    resultInt = 0;
                        string errorText = "";
                        foreach (int autoIdInt in autoIdList)
                        {
                            SqlCommand   cmd_proc = new SqlCommand("", conn, trans);
                            SqlParameter p1       = new SqlParameter("@AutoId", SqlDbType.Int);
                            p1.Value = autoIdInt;
                            SqlParameter p2 = new SqlParameter("@ReqDate", SqlDbType.DateTime);
                            p2.Value = reqDate;
                            IDataParameter[] updateParas = new IDataParameter[] { p1, p2 };
                            BaseSQL.RunProcedure(cmd_proc, "P_PSBom_UpdateReqDate", updateParas, out resultInt, out errorText);
                            if (resultInt != 1)
                            {
                                trans.Rollback();
                                MessageHandler.ShowMessageBox("更新生产计划单的Bom信息的需求日期错误--" + errorText);
                            }

                            string logStr = string.Format("生产计划单[{0}]更新Bom零件节点的需求日期,ID为[{1}],需求日期为[{2}]", psNoStr, autoIdInt, reqDate.ToString("yyyy-MM-dd"));
                            LogHandler.RecordLog(cmd, logStr);
                        }

                        trans.Commit();
                    }
                    catch (Exception ex)
                    {
                        trans.Rollback();
                        throw ex;
                    }
                    finally
                    {
                        conn.Close();
                    }
                }
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// 删除生产计划Bom信息
        /// </summary>
        public bool DeleteProductionScheduleBom(List <int> psBomAutoIdList)
        {
            using (SqlConnection conn = new SqlConnection(BaseSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        SqlCommand cmd = new SqlCommand("", conn, trans);

                        int    resultInt = 0;
                        string errorText = "";
                        string sqlwhere  = "";
                        foreach (int psBomAutoId in psBomAutoIdList)
                        {
                            sqlwhere += psBomAutoId + ",";
                        }
                        cmd.CommandText = string.Format("select Count(*) from PB_ScheduleAbsorbe where MainAutoId in ({0})", sqlwhere.Substring(0, sqlwhere.Length - 1));
                        int count = DataTypeConvert.GetInt(cmd.ExecuteScalar());
                        if (count > 0)
                        {
                            if (MessageHandler.ShowMessageBox_YesNo(string.Format("当前选中的生产计划记录包括{0}条吸收的生产计划记录,是否继续删除?", count)) != System.Windows.Forms.DialogResult.Yes)
                            {
                                trans.Rollback();
                                return(false);
                            }
                        }

                        cmd.CommandText = string.Format("Select Count(*) from PB_ProductionScheduleBom where AutoId in ({0}) and IsNull(PrReqNo, '') != ''", sqlwhere.Substring(0, sqlwhere.Length - 1));
                        if (DataTypeConvert.GetInt(cmd.ExecuteScalar()) > 0)
                        {
                            trans.Rollback();
                            MessageHandler.ShowMessageBox("当前选中的生产计划信息已经生成请购单,不可以进行操作。");
                            return(false);
                        }

                        foreach (int psBomAutoId in psBomAutoIdList)
                        {
                            string logStr = string.Format("删除生产计划Bom信息:[AutoId]的值[{0}]。", psBomAutoId);
                            LogHandler.RecordLog(cmd, logStr);

                            SqlCommand   cmd_proc = new SqlCommand("", conn, trans);
                            SqlParameter p1       = new SqlParameter("@AutoId", SqlDbType.Int);
                            p1.Value = psBomAutoId;
                            IDataParameter[] updateParas = new IDataParameter[] { p1 };
                            BaseSQL.RunProcedure(cmd_proc, "P_PSBom_Delete", updateParas, out resultInt, out errorText);
                            if (resultInt != 1)
                            {
                                trans.Rollback();
                                MessageHandler.ShowMessageBox("删除生产计划Bom信息错误--" + errorText);
                                return(false);
                            }
                        }

                        trans.Commit();
                        return(true);
                    }
                    catch (Exception ex)
                    {
                        trans.Rollback();
                        throw ex;
                    }
                    finally
                    {
                        conn.Close();
                    }
                }
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// 保存生产计划Bom信息
        /// </summary>
        public bool SaveProductionScheduleBom(int bomListAutoId, int psBomAutoId, int isAll, DateTime planDate, double remainQty, int isBuy, int isChildLevel)
        {
            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 Count(*) from PB_ScheduleAbsorbe where MainAutoId in ({0})", psBomAutoId);
                        int count = DataTypeConvert.GetInt(cmd.ExecuteScalar());
                        if (count > 0)
                        {
                            if (MessageHandler.ShowMessageBox_YesNo("当前选中的生产计划记录是吸收的生产计划记录,是否继续修改?") != System.Windows.Forms.DialogResult.Yes)
                            {
                                trans.Rollback();
                                return(false);
                            }
                        }

                        cmd.CommandText = string.Format("Select PrReqNo from PB_ProductionScheduleBom where AutoId = {0}", psBomAutoId);
                        if (DataTypeConvert.GetString(cmd.ExecuteScalar()) != "")
                        {
                            trans.Rollback();
                            MessageHandler.ShowMessageBox("当前修改的生产计划信息已经生成请购单,不可以进行操作。");
                            return(false);
                        }

                        int    resultInt = 0;
                        string errorText = "";
                        string logStr    = string.Format("保存生产计划Bom信息:[BomListAutoId]的值[{0}],[是否统一]的值[{1}],[需求日期]的值[{2}],[需求数量]的值[{3}],[是否购买]的值[{4}]。", bomListAutoId, isAll, planDate.ToString("yyyy-MM-dd"), remainQty, isBuy);
                        LogHandler.RecordLog(cmd, logStr);

                        SqlCommand   cmd_proc = new SqlCommand("", conn, trans);
                        SqlParameter p1       = new SqlParameter("@BomListAutoId", SqlDbType.Int);
                        p1.Value = bomListAutoId;
                        SqlParameter p2 = new SqlParameter("@AutoId", SqlDbType.Int);
                        p2.Value = psBomAutoId;
                        SqlParameter p3 = new SqlParameter("@IsAll", SqlDbType.Int);
                        p3.Value = isAll;
                        SqlParameter p4 = new SqlParameter("@PlanDate", SqlDbType.DateTime);
                        p4.Value = planDate;
                        SqlParameter p5 = new SqlParameter("@RemainQty", SqlDbType.Float);
                        p5.Value = remainQty;
                        SqlParameter p6 = new SqlParameter("@IsBuy", SqlDbType.Int);
                        p6.Value = isBuy;
                        SqlParameter p7 = new SqlParameter("@Creator", SqlDbType.Int);
                        p7.Value = SystemInfo.user.AutoId;
                        SqlParameter p8 = new SqlParameter("@PreparedIp", SqlDbType.VarChar);
                        p8.Value = SystemInfo.HostIpAddress;
                        IDataParameter[] updateParas = new IDataParameter[] { p1, p2, p3, p4, p5, p6, p7, p8 };
                        BaseSQL.RunProcedure(cmd_proc, "P_PSBom_Insert", updateParas, out resultInt, out errorText);
                        if (resultInt != 1)
                        {
                            trans.Rollback();
                            MessageHandler.ShowMessageBox("保存生产计划Bom信息错误--" + errorText);
                            return(false);
                        }

                        if (isChildLevel == 1)
                        {
                            SqlCommand   cmd_proclevel = new SqlCommand("", conn, trans);
                            SqlParameter para1         = new SqlParameter("@BomListAutoId", SqlDbType.Int);
                            para1.Value = bomListAutoId;
                            SqlParameter para2 = new SqlParameter("@IsAll", SqlDbType.Int);
                            para2.Value = isAll;
                            SqlParameter para3 = new SqlParameter("@PlanDate", SqlDbType.DateTime);
                            para3.Value = planDate;
                            SqlParameter para4 = new SqlParameter("@ParentRemainQty", SqlDbType.Float);
                            para4.Value = remainQty;
                            SqlParameter para5 = new SqlParameter("@Creator", SqlDbType.Int);
                            para5.Value = SystemInfo.user.AutoId;
                            SqlParameter para6 = new SqlParameter("@PreparedIp", SqlDbType.VarChar);
                            para6.Value = SystemInfo.HostIpAddress;
                            IDataParameter[] updateParameters = new IDataParameter[] { para1, para2, para3, para4, para5, para6 };
                            BaseSQL.RunProcedure(cmd_proclevel, "P_PSBom_Insert_SubLevel", updateParameters, out resultInt, out errorText);
                            if (resultInt != 1)
                            {
                                trans.Rollback();
                                MessageHandler.ShowMessageBox("保存子级生产计划Bom信息错误--" + errorText);
                                return(false);
                            }
                        }

                        trans.Commit();
                        return(true);
                    }
                    catch (Exception ex)
                    {
                        trans.Rollback();
                        throw ex;
                    }
                    finally
                    {
                        conn.Close();
                    }
                }
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// 删除设计Bom信息
        /// </summary>
        public int DeleteDesignBom(string salesOrderNoStr, List <string> pbBomNoList)
        {
            int countInt = 0;

            foreach (string pbBomNoStr in pbBomNoList)
            {
                string    sqlStr   = string.Format("select * from PB_DesignBomList where SalesOrderNo = '{0}' and PbBomNo = '{1}' and ParentId = 0", salesOrderNoStr, pbBomNoStr);
                DataTable bomTable = BaseSQL.Query(sqlStr).Tables[0];
                if (bomTable.Rows.Count == 0)
                {
                    MessageHandler.ShowMessageBox(string.Format("未查询到当前要操作的设计Bom信息[{0}],请查询后重新操作。", pbBomNoStr));
                    return(0);
                }
                //else
                //{
                //    int hasLevelInt = DataTypeConvert.GetInt(bomTable.Rows[0]["HasLevel"]);
                //    if (hasLevelInt == 0)
                //    {
                //        if (DeleteDesignBom_PartsCode(salesOrderNoStr, pbBomNoStr))
                //            countInt++;
                //        else
                //            return countInt;
                //    }
                //    else
                //    {
                //        if (DeleteDesignBom_Bom(salesOrderNoStr, pbBomNoStr))
                //            countInt++;
                //        else
                //            return countInt;
                //    }
                //}
            }


            using (SqlConnection conn = new SqlConnection(BaseSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        SqlCommand cmd = new SqlCommand("", conn, trans);

                        int    resultInt = 0;
                        string errorText = "";
                        foreach (string pbBomNoStr in pbBomNoList)
                        {
                            string logStr = string.Format("删除设计Bom中的信息[{0}]。", pbBomNoStr);
                            LogHandler.RecordLog(cmd, logStr);

                            SqlCommand   cmd_proc = new SqlCommand("", conn, trans);
                            SqlParameter p1       = new SqlParameter("@SalesOrderNo", SqlDbType.VarChar);
                            p1.Value = salesOrderNoStr;
                            SqlParameter p2 = new SqlParameter("@PbBomNo", SqlDbType.VarChar);
                            p2.Value = pbBomNoStr;
                            IDataParameter[] updateParas = new IDataParameter[] { p1, p2 };
                            BaseSQL.RunProcedure(cmd_proc, "P_DesignBom_Delete", updateParas, out resultInt, out errorText);
                            if (resultInt != 1)
                            {
                                trans.Rollback();
                                MessageHandler.ShowMessageBox("设计Bom删除信息错误--" + errorText);
                                return(0);
                            }
                        }
                        trans.Commit();
                        countInt = pbBomNoList.Count;
                    }
                    catch (Exception ex)
                    {
                        trans.Rollback();
                        throw ex;
                    }
                    finally
                    {
                        conn.Close();
                    }
                }
            }

            return(countInt);
        }
Exemplo n.º 15
0
        /// <summary>
        /// 保存设计Bom信息处理Bom方法
        /// </summary>
        private bool SaveDesignBom_Bom(string salesOrderNoStr, string codeFileNameStr, float qty)
        {
            using (SqlConnection conn = new SqlConnection(BaseSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        SqlCommand cmd = new SqlCommand("", conn, trans);

                        int    resultInt = 0;
                        string errorText = "";

                        string pbBomNo = "";

                        string logStr = string.Format("设计Bom信息增加Bom[{0}],数量为[{1}]。", codeFileNameStr, qty);
                        LogHandler.RecordLog(cmd, logStr);

                        cmd.CommandText = string.Format("select * from PB_DesignBomList where SalesOrderNo = '{0}' and MaterielNo = '{1}' and RemainQty > 0 and ParentId = 0", salesOrderNoStr, codeFileNameStr);
                        DataTable bomMagTable = BaseSQL.GetTableBySql(cmd);
                        if (bomMagTable.Rows.Count > 0)//更新数量
                        {
                            if (qty < 0)
                            {
                                if (DataTypeConvert.GetDouble(bomMagTable.Rows[0]["RemainQty"]) + qty < 0)
                                {
                                    MessageHandler.ShowMessageBox("Bom修改后的数量必须大于等于0。");
                                    return(false);
                                }
                            }
                            pbBomNo = DataTypeConvert.GetString(bomMagTable.Rows[0]["PbBomNo"]);

                            SqlCommand   cmd_proc = new SqlCommand("", conn, trans);
                            SqlParameter p1       = new SqlParameter("@PbBomNo", SqlDbType.VarChar);
                            p1.Value = pbBomNo;
                            SqlParameter p2 = new SqlParameter("@Qty", SqlDbType.Float);
                            p2.Value = qty;
                            IDataParameter[] updateParas = new IDataParameter[] { p1, p2 };
                            BaseSQL.RunProcedure(cmd_proc, "P_DesignBom_Bom_UpdateQty", updateParas, out resultInt, out errorText);
                            if (resultInt != 1)
                            {
                                trans.Rollback();
                                MessageHandler.ShowMessageBox("设计Bom更新Bom信息错误--" + errorText);
                                return(false);
                            }
                        }
                        else//新增记录
                        {
                            pbBomNo = BaseSQL.GetMaxCodeNo(cmd, "PB");

                            SqlCommand   cmd_proc = new SqlCommand("", conn, trans);
                            SqlParameter p1       = new SqlParameter("@SalesOrderNo", SqlDbType.VarChar);
                            p1.Value = salesOrderNoStr;
                            SqlParameter p2 = new SqlParameter("@PbBomNo", SqlDbType.VarChar);
                            p2.Value = pbBomNo;
                            SqlParameter p3 = new SqlParameter("@CodeFileName", SqlDbType.VarChar);
                            p3.Value = codeFileNameStr;
                            SqlParameter p4 = new SqlParameter("@Qty", SqlDbType.Float);
                            p4.Value = qty;
                            SqlParameter p5 = new SqlParameter("@Creator", SqlDbType.Int);
                            p5.Value = SystemInfo.user.AutoId;
                            SqlParameter p6 = new SqlParameter("@PreparedIp", SqlDbType.VarChar);
                            p6.Value = SystemInfo.HostIpAddress;
                            IDataParameter[] insertParas = new IDataParameter[] { p1, p2, p3, p4, p5, p6 };
                            BaseSQL.RunProcedure(cmd_proc, "P_DesignBom_Bom_Insert", insertParas, out resultInt, out errorText);
                            if (resultInt != 1)
                            {
                                trans.Rollback();
                                MessageHandler.ShowMessageBox("设计Bom新增Bom信息错误--" + errorText);
                                return(false);
                            }
                        }

                        //进行吸收其他Bom和零件
                        SqlCommand   cmd_Absorb = new SqlCommand("", conn, trans);
                        SqlParameter p1_Absorb  = new SqlParameter("@SalesOrderNo", SqlDbType.VarChar);
                        p1_Absorb.Value = salesOrderNoStr;
                        SqlParameter p2_Absorb = new SqlParameter("@PbBomNo", SqlDbType.VarChar);
                        p2_Absorb.Value = pbBomNo;
                        SqlParameter p3_Absorb = new SqlParameter("@MainBomAutoId", SqlDbType.Int);
                        p3_Absorb.Value = 0;
                        SqlParameter p4_Absorb = new SqlParameter("@ParentId", SqlDbType.Int);
                        p4_Absorb.Value = 0;
                        SqlParameter p5_Absorb = new SqlParameter("@OpQty", SqlDbType.Float);
                        p5_Absorb.Value = qty;
                        IDataParameter[] parameters = new IDataParameter[] { p1_Absorb, p2_Absorb, p3_Absorb, p4_Absorb, p5_Absorb };
                        BaseSQL.RunProcedure(cmd_Absorb, "P_DesignBom_Bom_Absorbed", parameters, out resultInt, out errorText);
                        if (resultInt != 1)
                        {
                            trans.Rollback();
                            MessageHandler.ShowMessageBox("设计Bom吸收Bom和零件数量错误--" + errorText);
                            return(false);
                        }
                        //没有被动吸收 被其他Bom吸收

                        trans.Commit();
                        return(true);
                    }
                    catch (Exception ex)
                    {
                        trans.Rollback();
                        throw ex;
                    }
                    finally
                    {
                        conn.Close();
                    }
                }
            }
        }