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

            using (IDbConnection conn = ClsCommon.OpenConnection())  //这里访问的是Sqlite数据文件,这里OpenConnection即上边获取连接数据库对象方法
            {
                result = conn.Delete(pcb);
            }
            return(Convert.ToInt32(result));
        }
        public static int DeleteProductionRecipe(AsmRecipeObject aro)
        {
            parameters = new List <DbParameter>();
            parameters.Add(ClsCommon.dbSql.CreateDbParameter("@RECIPE_ID", ParameterDirection.Input, aro.RECIPE_ID));
            parameters.Add(ClsCommon.dbSql.CreateDbParameter("@NAME", ParameterDirection.Input, aro.RECIPE_NAME));
            parameters.Add(ClsCommon.dbSql.CreateDbParameter("@DISCRIPTION", ParameterDirection.Input, aro.RECIPE_DISCRIPTION));
            parameters.Add(ClsCommon.dbSql.CreateDbParameter("@R", ParameterDirection.Output, ""));
            ClsCommon.dbSql.ExecuteNonQuery("F_ASM_DELETEPRODUCTIONRECIPE_P", parameters, CommandType.StoredProcedure);
            object bj = parameters[parameters.Count - 1].Value.ToString();

            return(Convert.ToInt32(bj));
        }
        public static AsmRecipeObject GetRecipeByCondition(string sql)
        {
            AsmRecipeObject pcbo = null;
            string          sl   = "SELECT RECIPE_ID,RECIPE_NAME,RECIPE_DISCRIPTION FROM dbo.C_ASM_RECIPE_T WHERE " + sql;
            DataTable       dt   = new DataTable();

            dt = ClsCommon.dbSql.ExecuteDataTable(sl);
            if (dt.Rows.Count > 0)
            {
                pcbo                    = new AsmRecipeObject();
                pcbo.RECIPE_ID          = Convert.ToInt32(dt.Rows[0]["RECIPE_ID"].ToString());
                pcbo.RECIPE_NAME        = dt.Rows[0]["RECIPE_NAME"].ToString();
                pcbo.RECIPE_DISCRIPTION = dt.Rows[0]["RECIPE_DISCRIPTION"].ToString();
            }
            return(pcbo);
        }
Exemple #5
0
 /// <summary>
 /// 删除
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void BT_RD_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("删除配方,将删除对应的详细信息,确认删除?", "删除提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
     {
         int             row  = DGV_R.SelectedRows[0].Index;
         AsmRecipeObject pcbo = new AsmRecipeObject();
         pcbo.RECIPE_ID          = Convert.ToInt32(recipeDt.Rows[row]["RECIPE_ID"].ToString());
         pcbo.RECIPE_NAME        = recipeDt.Rows[row]["RECIPE_NAME"].ToString();
         pcbo.RECIPE_DISCRIPTION = recipeDt.Rows[row]["RECIPE_DISCRIPTION"].ToString();
         if (AsmRecipe_BLL.DeleteProductionRecipe(pcbo) == 0)
         {
             MessageBox.Show("删除配方成功......");
             ProductionRecipeRefish();
             TB_RN.Text         = "";
             TB_RD.Text         = "";
             CB_RP.SelectedItem = null;
             CB_S.SelectedItem  = null;
         }
         else
         {
             MessageBox.Show("删除配方失败......");
         }
     }
 }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="aro"></param>
        /// <returns></returns>
        public static int DeleteProductionRecipe(AsmRecipeObject aro)
        {
            int a = AsmRecipe_DAL.DeleteProductionRecipe(aro);

            return(a);
        }
        public static int DeleteRecipeByObject(AsmRecipeObject pcb)
        {
            int a = AsmRecipe_DAL.DeleteRecipeByObject(pcb);

            return(a);
        }
        public static AsmRecipeObject GetRecipeByCondition(string sql)
        {
            AsmRecipeObject aro = AsmRecipe_DAL.GetRecipeByCondition(sql);

            return(aro);
        }
        public static AsmRecipeObject GetAsmRecipeByObject(string sql)
        {
            AsmRecipeObject aro = AsmRecipe_DAL.GetAsmRecipeByObject(sql);

            return(aro);
        }
Exemple #10
0
        public static int UpdateAsmRecipeByObject(AsmRecipeObject pcb)
        {
            int a = AsmRecipe_DAL.UpdateAsmRecipeByObject(pcb);

            return(a);
        }
Exemple #11
0
        public static int AddAsmRecipeByObject(AsmRecipeObject aro)
        {
            int a = AsmRecipe_DAL.AddAsmRecipeByObject(aro);

            return(a);
        }
Exemple #12
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;
        }