Ejemplo n.º 1
0
        public bool MatPrepareUpdate(matPlanBLL u)
        {
            bool          isSuccess = false;
            SqlConnection conn      = new SqlConnection(myconnstrng);

            try
            {
                String sql = @"UPDATE tbl_matplan 
                            SET "
                             + Prepare + "=@mat_preparing, "
                             + Transferred + "=@mat_transferred, "
                             + MatFrom + "=@mat_from, "
                             + UpdatedDate + "=@updated_date, "
                             + UpdatedBy + "=@updated_by " +
                             " WHERE mat_code=@mat_code AND plan_id=@plan_id";

                SqlCommand cmd = new SqlCommand(sql, conn);

                cmd.Parameters.AddWithValue("@mat_code", u.mat_code);
                cmd.Parameters.AddWithValue("@plan_id", u.plan_id);
                cmd.Parameters.AddWithValue("@mat_transferred", u.mat_transferred);
                cmd.Parameters.AddWithValue("@mat_preparing", u.mat_preparing);
                cmd.Parameters.AddWithValue("@mat_from", u.mat_from);
                cmd.Parameters.AddWithValue("@updated_date", u.updated_date);
                cmd.Parameters.AddWithValue("@updated_by", u.updated_by);

                conn.Open();

                int rows = cmd.ExecuteNonQuery();

                //if the query is executed successfully then the rows' value = 0
                if (rows > 0)
                {
                    //query successful
                    isSuccess = true;
                }
                else
                {
                    //Query falled
                    isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                Module.Tool tool = new Module.Tool();
                tool.saveToText(ex);
            }
            finally
            {
                conn.Close();
            }
            return(isSuccess);
        }
        public frmMatAddOrEdit(matPlanBLL u, bool addingMaterial)
        {
            InitializeComponent();

            editMode = true;
            addMode  = addingMaterial;
            uMatPlan = u;
            loadItemCategoryData();

            cmbParentName.Text = u.part_name;
            cmbParentCode.Text = u.part_code;
            cmbPlanID.Items.Add(u.plan_id.ToString());
            cmbPlanID.SelectedIndex = 0;

            txtFac.Text = u.pro_location;
            txtMac.Text = u.pro_machine;

            txtAblePro.Text   = u.pro_max_qty;
            txtTargetQty.Text = u.pro_target_qty;

            txtStart.Text = Convert.ToDateTime(u.pro_start).ToShortDateString();
            txtEnd.Text   = Convert.ToDateTime(u.pro_end).ToShortDateString();

            if (!addingMaterial)
            {
                cmbChildCat.Text = u.mat_cat;

                cmbChildName.Items.Add(u.mat_name);
                cmbChildName.SelectedIndex = 0;

                cmbChildCode.Items.Add(u.mat_code);
                cmbChildCode.SelectedIndex = 0;

                txtMatUseQty.Text = u.plan_to_use.ToString();

                cmbChildCat.Enabled  = false;
                cmbChildName.Enabled = false;
                cmbChildCode.Enabled = false;
            }

            cmbParentName.Enabled = false;
            cmbParentCode.Enabled = false;
            cmbPlanID.Enabled     = false;

            updateTestName();
        }
        public frmMatAddOrEdit(DataTable dt, matPlanBLL u, string ParentCode, bool AddMaterial)
        {
            InitializeComponent();
            dt_matplan = dt;

            if (!AddMaterial)
            {
                editMode = false;
            }

            addMode = AddMaterial;

            loadItemCategoryData();

            cmbParentName.Text = tool.getItemName(ParentCode);
            cmbParentCode.Text = ParentCode;

            loadPlanID();
            LoadPlanData(u.plan_id);
            if (!AddMaterial)
            {
                editMode         = true;
                cmbChildCat.Text = u.mat_cat;

                cmbChildName.Items.Add(u.mat_name);
                cmbChildName.SelectedIndex = 0;

                cmbChildCode.Items.Add(u.mat_code);
                cmbChildCode.SelectedIndex = 0;

                txtMatUseQty.Text = u.plan_to_use.ToString();

                cmbChildCat.Enabled  = false;
                cmbChildName.Enabled = false;
                cmbChildCode.Enabled = false;
            }

            cmbPlanID.SelectedIndex = 0;
            cmbParentName.Enabled   = false;
            cmbParentCode.Enabled   = false;
            //cmbPlanID.Enabled = false;

            updateTestName();
        }
Ejemplo n.º 4
0
        public bool Update(matPlanBLL u)
        {
            bool          isSuccess = false;
            SqlConnection conn      = new SqlConnection(myconnstrng);

            try
            {
                String sql = @"UPDATE tbl_matplan 
                            SET "
                             + PlanToUse + "=@plan_to_use" +
                             " WHERE mat_code=@mat_code";

                SqlCommand cmd = new SqlCommand(sql, conn);

                cmd.Parameters.AddWithValue("@mat_code", u.mat_code);
                cmd.Parameters.AddWithValue("@plan_to_use", u.plan_to_use);
                conn.Open();

                int rows = cmd.ExecuteNonQuery();

                //if the query is executed successfully then the rows' value = 0
                if (rows > 0)
                {
                    //query successful
                    isSuccess = true;
                }
                else
                {
                    //Query falled
                    isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                Module.Tool tool = new Module.Tool(); tool.saveToText(ex);
            }
            finally
            {
                conn.Close();
            }
            return(isSuccess);
        }
Ejemplo n.º 5
0
        public bool Insert(matPlanBLL u)
        {
            bool          isSuccess = false;
            SqlConnection conn      = new SqlConnection(myconnstrng);

            try
            {
                String sql = @"INSERT INTO tbl_matplan 
                            (" + MatCode + ","
                             + PlanID + ","
                             + PlanToUse + ","
                             + MatUsed + ","
                             + Active + ","
                             + MatNote + ","
                             + UpdatedDate + ","
                             + UpdatedBy + ") VALUES" +
                             "(@mat_code,@plan_id," +
                             "@plan_to_use," +
                             "@mat_used," +
                             "@active," +
                             "@mat_note," +
                             "@updated_date," +
                             "@updated_by)";

                SqlCommand cmd = new SqlCommand(sql, conn);

                cmd.Parameters.AddWithValue("@mat_code", u.mat_code);
                cmd.Parameters.AddWithValue("@plan_id", u.plan_id);
                cmd.Parameters.AddWithValue("@plan_to_use", u.plan_to_use);
                cmd.Parameters.AddWithValue("@mat_used", u.mat_used);
                cmd.Parameters.AddWithValue("@active", u.active);
                cmd.Parameters.AddWithValue("@mat_note", u.mat_note);
                cmd.Parameters.AddWithValue("@updated_date", u.updated_date);
                cmd.Parameters.AddWithValue("@updated_by", u.updated_by);

                conn.Open();

                int rows = cmd.ExecuteNonQuery();

                //if the query is executed successfully then the rows' value = 0
                if (rows > 0)
                {
                    //query successful
                    isSuccess = true;
                }
                else
                {
                    //Query falled
                    isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                Module.Tool tool = new Module.Tool(); tool.saveToTextAndMessageToUser(ex);
            }
            finally
            {
                conn.Close();
            }
            return(isSuccess);
        }