Example #1
0
 public static int AddProductionRecipeByObject(AsmProductionRecipeObject apro)
 {
     using (IDbConnection conn = ClsCommon.OpenConnection())  //这里访问的是Sqlite数据文件,这里OpenConnection即上边获取连接数据库对象方法
     {
         var result = conn.Insert(apro);
         return(Convert.ToInt32(result));
     }
 }
Example #2
0
        public static int DeleteProductionRecipeByObject(AsmProductionRecipeObject pcb)
        {
            var result = 0;

            using (IDbConnection conn = ClsCommon.OpenConnection())  //这里访问的是Sqlite数据文件,这里OpenConnection即上边获取连接数据库对象方法
            {
                result = conn.Delete(pcb);
            }
            return(Convert.ToInt32(result));
        }
Example #3
0
        public static AsmProductionRecipeObject GetProductionRecipeByProAndSta(int productionId, string stationName)
        {
            AsmProductionRecipeObject apro = null;
            string    sql = "SELECT APR.PRODUCTION_RECIPE_ID,APR.PRODUCTION_ID,APR.RECIPE_ID,APR.STATION_ID  FROM dbo.C_ASM_PRODUCTION_RECIPE_T APR,C_ASM_STATION_T AST WHERE AST.STATION_ID=APR.STATION_ID AND APR.PRODUCTION_ID=" + productionId + " AND AST.STATION_NAME='" + stationName + "'";
            DataTable dt  = new DataTable();

            dt = ClsCommon.dbSql.ExecuteDataTable(sql);
            if (dt.Rows.Count > 0)
            {
                apro = new AsmProductionRecipeObject();
                apro.PRODUCTION_RECIPE_ID = Convert.ToInt32(dt.Rows[0]["PRODUCTION_RECIPE_ID"].ToString());
                apro.PRODUCTION_ID        = Convert.ToInt32(dt.Rows[0]["PRODUCTION_ID"].ToString());
                apro.RECIPE_ID            = Convert.ToInt32(dt.Rows[0]["RECIPE_ID"].ToString());
                apro.STATION_ID           = Convert.ToInt32(dt.Rows[0]["STATION_ID"].ToString());
            }
            return(apro);
        }
Example #4
0
        public static AsmProductionRecipeObject GetProductionRecipeCondition(string sl)
        {
            AsmProductionRecipeObject apro = null;
            string    sql = "SELECT PRODUCTION_RECIPE_ID,PRODUCTION_ID,RECIPE_ID,STATION_ID  FROM dbo.C_ASM_PRODUCTION_RECIPE_T WHERE  " + sl;
            DataTable dt  = new DataTable();

            dt = ClsCommon.dbSql.ExecuteDataTable(sql);
            if (dt.Rows.Count > 0)
            {
                apro = new AsmProductionRecipeObject();
                apro.PRODUCTION_RECIPE_ID = Convert.ToInt32(dt.Rows[0]["PRODUCTION_RECIPE_ID"].ToString());
                apro.PRODUCTION_ID        = Convert.ToInt32(dt.Rows[0]["PRODUCTION_ID"].ToString());
                apro.RECIPE_ID            = Convert.ToInt32(dt.Rows[0]["RECIPE_ID"].ToString());
                apro.STATION_ID           = Convert.ToInt32(dt.Rows[0]["STATION_ID"].ToString());
            }
            return(apro);
        }
Example #5
0
        public static List <AsmProductionRecipeObject> GetManyProductionRecipeObjectByCondition(string sql)
        {
            List <AsmProductionRecipeObject> ar = new List <AsmProductionRecipeObject>();
            string    sl = "SELECT PRODUCTION_RECIPE_ID,PRODUCTION_ID,RECIPE_ID,STATION_ID FROM C_ASM_PRODUCTION_RECIPE_T WHERE " + sql;
            DataTable dt = new DataTable();

            dt = ClsCommon.dbSql.ExecuteDataTable(sl);
            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    AsmProductionRecipeObject aro = new AsmProductionRecipeObject();
                    aro.PRODUCTION_RECIPE_ID = Convert.ToInt32(dt.Rows[i]["PRODUCTION_RECIPE_ID"].ToString());
                    aro.PRODUCTION_ID        = Convert.ToInt32(dt.Rows[i]["PRODUCTION_ID"].ToString());
                    aro.RECIPE_ID            = Convert.ToInt32(dt.Rows[i]["RECIPE_ID"].ToString());
                    aro.STATION_ID           = Convert.ToInt32(dt.Rows[i]["STATION_ID"].ToString());
                    ar.Add(aro);
                }
            }
            return(ar);
        }
        public static int DeleteProductionRecipeByObject(AsmProductionRecipeObject pcb)
        {
            int a = AsmProductionRecipe_DAL.DeleteProductionRecipeByObject(pcb);

            return(a);
        }
        public static AsmProductionRecipeObject GetProductionRecipeByProAndSta(int productionId, string stationName)
        {
            AsmProductionRecipeObject apro = AsmProductionRecipe_DAL.GetProductionRecipeByProAndSta(productionId, stationName);

            return(apro);
        }
        public static AsmProductionRecipeObject GetProductionRecipeCondition(string sl)
        {
            AsmProductionRecipeObject apro = AsmProductionRecipe_DAL.GetProductionRecipeCondition(sl);

            return(apro);
        }
        public static int UpdateProductionRecipeByObject(AsmProductionRecipeObject apro)
        {
            int a = AsmProductionRecipe_DAL.UpdateProductionRecipeByObject(apro);

            return(a);
        }
Example #10
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BT_RS_Click(object sender, EventArgs e)
        {
            AsmRecipeObject                  aro   = null;
            AsmProductionRecipeObject        apro  = null;
            List <AsmProductionRecipeObject> lapro = null;
            int selectValue;
            int stationSelectValue;

            if (!String.IsNullOrEmpty(TB_RN.Text))
            {
                #region
                aro = AsmRecipe_BLL.GetRecipeByCondition(" RECIPE_NAME='" + TB_RN.Text.Trim() + "'");
                #region >>>>>处理产品下拉选项的只  不选则为0
                if (CB_RP.SelectedValue == null)
                {
                    if (CB_S.SelectedValue == null)
                    {
                        selectValue        = 0;
                        stationSelectValue = 0;
                    }
                    else
                    {
                        selectValue        = 0;
                        stationSelectValue = 0;
                        CB_S.SelectedItem  = null;
                    }
                }
                else
                {
                    if (CB_S.SelectedValue != null)
                    {
                        selectValue        = Convert.ToInt32(CB_RP.SelectedValue);
                        stationSelectValue = Convert.ToInt32(CB_S.SelectedValue);
                    }
                    else
                    {
                        MessageBox.Show("已选择产品,请选择对应的工位......");
                        return;
                    }
                }
                #endregion
                if (aro != null)
                {
                    #region
                    lapro = AsmProductionRecipe_BLL.GetManyProductionRecipeObjectByCondition(" RECIPE_ID=" + aro.RECIPE_ID);
                    if (lapro.Count > 0)
                    {
                        for (int i = 0; i < lapro.Count; i++)
                        {
                            #region >>>>> 有关联产品
                            if (selectValue == lapro[i].PRODUCTION_ID && stationSelectValue == lapro[i].STATION_ID)//判读是否绑定同一产品
                            {
                                #region >>>>>更新本BOM
                                aro.RECIPE_NAME        = TB_RN.Text.Trim();
                                aro.RECIPE_DISCRIPTION = TB_RD.Text.Trim();
                                if (AsmRecipe_BLL.UpdateAsmRecipeByObject(aro) > 0)
                                {
                                    MessageBox.Show("更新配方成功......");
                                    TB_RN.Text         = "";
                                    TB_RD.Text         = "";
                                    CB_RP.SelectedItem = null;
                                    CB_S.SelectedItem  = null;
                                    PL_ADF.Visible     = false;
                                    edditRemark        = true;
                                    ProductionRecipeRefish();
                                    return;
                                }
                                else
                                {
                                    MessageBox.Show("更新配方信息失败......");
                                    return;
                                }
                                #endregion
                            }
                            #endregion
                        }
                        AsmProductionRecipeObject apro1 = AsmProductionRecipe_BLL.GetProductionRecipeCondition(" PRODUCTION_ID=" + selectValue + " AND  STATION_ID=" + stationSelectValue);
                        if (apro1 == null)
                        {
                            #region >>>>>更新本BOM和新增产品关联
                            aro.RECIPE_NAME        = TB_RN.Text.Trim();
                            aro.RECIPE_DISCRIPTION = TB_RD.Text.Trim();
                            if (AsmRecipe_BLL.UpdateAsmRecipeByObject(aro) > 0)
                            {
                                #region >>>>>新增BOM和产品关联
                                AsmProductionRecipeObject pr = new AsmProductionRecipeObject();
                                pr.PRODUCTION_ID = selectValue;
                                pr.RECIPE_ID     = aro.RECIPE_ID;
                                pr.STATION_ID    = stationSelectValue;
                                if (AsmProductionRecipe_BLL.AddProductionRecipeByObject(pr) > 0)
                                {
                                    MessageBox.Show("更新配方成功......");
                                    TB_RN.Text         = "";
                                    TB_RD.Text         = "";
                                    CB_RP.SelectedItem = null;
                                    CB_S.SelectedItem  = null;
                                    PL_ADF.Visible     = false;
                                    edditRemark        = true;
                                    ProductionRecipeRefish();
                                }
                                #endregion
                            }
                            else
                            {
                                CB_RP.SelectedItem = null;
                                CB_S.SelectedItem  = null;
                                ProductionRecipeRefish();
                                MessageBox.Show("更新配方信息失败......");
                            }
                            #endregion
                        }
                        else
                        {
                            MessageBox.Show("选中的产品在该工位已经绑定了配方,请先解绑后再进行操作......");
                            return;
                        }
                    }
                    else
                    {
                        #region >>>>> 无关联产品
                        if (selectValue == 0) //是否选择了关联产品
                        {
                            #region >>>>>更新本BOM
                            aro.RECIPE_NAME        = TB_RN.Text.Trim();
                            aro.RECIPE_DISCRIPTION = TB_RD.Text.Trim();
                            if (AsmRecipe_BLL.UpdateAsmRecipeByObject(aro) > 0)
                            {
                                MessageBox.Show("更新配方成功......");
                                TB_RN.Text         = "";
                                TB_RD.Text         = "";
                                CB_RP.SelectedItem = null;
                                CB_S.SelectedItem  = null;
                                PL_ADF.Visible     = false;
                                edditRemark        = true;
                                ProductionRecipeRefish();
                            }
                            else
                            {
                                MessageBox.Show("更新配方信息失败......");
                                return;
                            }
                            #endregion
                        }
                        else
                        {
                            #region >>>>>新增BOM和产品关联
                            apro = AsmProductionRecipe_BLL.GetProductionRecipeCondition(" PRODUCTION_ID=" + selectValue + " AND STATION_ID=" + stationSelectValue);
                            if (apro != null)
                            {
                                MessageBox.Show("选中的产品上已经绑定了配方,请先解绑后再进行操作......");
                            }
                            else
                            {
                                #region >>>>>新增BOM同时新增关联产品
                                aro.RECIPE_NAME        = TB_RN.Text.Trim();
                                aro.RECIPE_DISCRIPTION = TB_RD.Text.Trim();
                                if (AsmRecipe_BLL.UpdateAsmRecipeByObject(aro) > 0)
                                {
                                    aro = AsmRecipe_BLL.GetRecipeByCondition(" RECIPE_NAME='" + aro.RECIPE_NAME + "' AND RECIPE_DISCRIPTION='" + aro.RECIPE_DISCRIPTION + "';");
                                    AsmProductionRecipeObject p = new AsmProductionRecipeObject();
                                    p.PRODUCTION_ID = selectValue;
                                    p.RECIPE_ID     = aro.RECIPE_ID;
                                    p.STATION_ID    = stationSelectValue;
                                    if (AsmProductionRecipe_BLL.AddProductionRecipeByObject(p) > 0)
                                    {
                                        TB_RN.Text         = "";
                                        TB_RD.Text         = "";
                                        CB_RP.SelectedItem = null;
                                        CB_S.SelectedItem  = null;
                                        PL_ADF.Visible     = false;
                                        edditRemark        = true;
                                        ProductionRecipeRefish();
                                        MessageBox.Show("更新配方成功......");
                                    }
                                    else
                                    {
                                        CB_RP.SelectedItem = null;
                                        CB_S.SelectedItem  = null;
                                        ProductionRecipeRefish();
                                        MessageBox.Show("更新配方失败......");
                                    }
                                }
                                #endregion
                            }
                            #endregion
                        }
                        #endregion
                    }
                    #endregion
                }
                else
                {
                    #region >>>>>新增BOM或者新增BOM和产品关联
                    if (selectValue == 0) //新增BOM
                    {
                        #region
                        aro                    = new AsmRecipeObject();
                        aro.RECIPE_NAME        = TB_RN.Text.Trim();
                        aro.RECIPE_DISCRIPTION = TB_RD.Text.Trim();
                        if (AsmRecipe_BLL.AddAsmRecipeByObject(aro) > 0)
                        {
                            TB_RN.Text         = "";
                            TB_RD.Text         = "";
                            CB_RP.SelectedItem = null;
                            CB_S.SelectedItem  = null;
                            PL_ADF.Visible     = false;
                            edditRemark        = true;
                            ProductionRecipeRefish();
                            MessageBox.Show("新增配方成功......");
                        }
                        #endregion
                    }
                    else
                    {
                        #region >>>>>新增BOM和产品关联
                        apro = AsmProductionRecipe_BLL.GetProductionRecipeCondition(" PRODUCTION_ID=" + selectValue + " AND STATION_ID=" + stationSelectValue);
                        if (apro != null)
                        {
                            MessageBox.Show("选中的产品在该工位已经绑定了配方,请先解绑后再进行操作......");
                        }
                        else
                        {
                            #region >>>>>新增BOM同时新增关联产品
                            aro                    = new AsmRecipeObject();
                            aro.RECIPE_NAME        = TB_RN.Text.Trim();
                            aro.RECIPE_DISCRIPTION = TB_RD.Text.Trim();
                            if (AsmRecipe_BLL.AddAsmRecipeByObject(aro) > 0)
                            {
                                aro  = AsmRecipe_BLL.GetRecipeByCondition(" RECIPE_NAME='" + aro.RECIPE_NAME + "' AND RECIPE_DISCRIPTION='" + aro.RECIPE_DISCRIPTION + "';");
                                apro = new AsmProductionRecipeObject();
                                apro.PRODUCTION_ID = selectValue;
                                apro.RECIPE_ID     = aro.RECIPE_ID;
                                apro.STATION_ID    = stationSelectValue;
                                if (AsmProductionRecipe_BLL.AddProductionRecipeByObject(apro) > 0)
                                {
                                    TB_RN.Text         = "";
                                    TB_RD.Text         = "";
                                    CB_RP.SelectedItem = null;
                                    CB_S.SelectedItem  = null;
                                    PL_ADF.Visible     = false;
                                    edditRemark        = true;
                                    ProductionRecipeRefish();
                                    MessageBox.Show("新增配方成功......");
                                }
                                else
                                {
                                    AsmRecipe_BLL.DeleteProductionRecipe(aro);
                                    CB_RP.SelectedItem = null;
                                    CB_S.SelectedItem  = null;
                                    ProductionRecipeRefish();
                                    MessageBox.Show("新增配方失败......");
                                }
                            }
                            #endregion
                        }
                        #endregion
                    }
                    #endregion
                }
                #endregion
            }
            else
            {
                MessageBox.Show("已存在相同名字的配方......");
            }
            mark          = true;
            BT_RD.Enabled = false;
        }