Exemple #1
0
        public bool InsertProductionPackaging(ProductionRecordBLL u)
        {
            bool          isSuccess = false;
            SqlConnection conn      = new SqlConnection(myconnstrng);

            try
            {
                String sql = @"INSERT INTO tbl_pro_packaging
                            (" + SheetID + ","
                             + PackagingCode + ","
                             + PackagingQty + ","
                             + PackagingMax + ","
                             + UpdatedDate + ","
                             + UpdatedBy + ") VALUES" +
                             "(@sheet_id," +
                             "@packaging_code," +
                             "@packaging_qty," +
                             "@packaging_max," +
                             "@updated_date," +
                             "@updated_by)";

                SqlCommand cmd = new SqlCommand(sql, conn);

                cmd.Parameters.AddWithValue("@sheet_id", u.sheet_id);
                cmd.Parameters.AddWithValue("@packaging_code", u.packaging_code);
                cmd.Parameters.AddWithValue("@packaging_qty", u.packaging_qty);
                cmd.Parameters.AddWithValue("@packaging_max", u.packaging_max);
                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);
        }
Exemple #2
0
        public bool InsertSheetMeter(ProductionRecordBLL u)
        {
            bool          isSuccess = false;
            SqlConnection conn      = new SqlConnection(myconnstrng);

            try
            {
                String sql = @"INSERT INTO tbl_production_meter_reading
                            (" + SheetID + ","
                             + ProTime + ","
                             + ProOperator + ","
                             + ProMeterReading + ") VALUES" +
                             "(@sheet_id," +
                             "@time," +
                             "@production_operator," +
                             "@meter_reading)";

                SqlCommand cmd = new SqlCommand(sql, conn);

                cmd.Parameters.AddWithValue("@sheet_id", u.sheet_id);
                cmd.Parameters.AddWithValue("@time", u.time);
                cmd.Parameters.AddWithValue("@production_operator", u.production_operator);
                cmd.Parameters.AddWithValue("@meter_reading", u.meter_reading);

                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);
        }
Exemple #3
0
        public bool RemoveSheetData(ProductionRecordBLL u)
        {
            u.active = false;
            bool          isSuccess = false;
            SqlConnection conn      = new SqlConnection(myconnstrng);

            try
            {
                String sql = @"UPDATE tbl_production_record 
                            SET "
                             + UpdatedDate + "=@updated_date,"
                             + UpdatedBy + "=@updated_by,"
                             + Active + "=@active" +
                             " WHERE sheet_id=@sheet_id";

                SqlCommand cmd = new SqlCommand(sql, conn);

                cmd.Parameters.AddWithValue("@sheet_id", u.sheet_id);
                cmd.Parameters.AddWithValue("@updated_date", u.updated_date);
                cmd.Parameters.AddWithValue("@updated_by", u.updated_by);
                cmd.Parameters.AddWithValue("@active", u.active);

                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);
        }
Exemple #4
0
        public bool SheetMeterUpdate(ProductionRecordBLL u)
        {
            bool          isSuccess = false;
            SqlConnection conn      = new SqlConnection(myconnstrng);

            try
            {
                String sql = @"UPDATE tbl_production_meter_reading
                            SET "
                             + ProMeterReading + "=@meter_reading,"
                             + ProOperator + "=@production_operator" +
                             " WHERE sheet_id=@sheet_id AND time=@time";

                SqlCommand cmd = new SqlCommand(sql, conn);

                cmd.Parameters.AddWithValue("@sheet_id", u.sheet_id);
                cmd.Parameters.AddWithValue("@time", u.time);
                cmd.Parameters.AddWithValue("@production_operator", u.production_operator);
                cmd.Parameters.AddWithValue("@meter_reading", u.meter_reading);

                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);
        }
Exemple #5
0
        public bool TempCommand(ProductionRecordBLL u)
        {
            bool          isSuccess = false;
            SqlConnection conn      = new SqlConnection(myconnstrng);

            try
            {
                String sql = @"UPDATE tbl_production_record 
                            SET "
                             + Active + "=@active";

                SqlCommand cmd = new SqlCommand(sql, conn);

                cmd.Parameters.AddWithValue("@active", u.active);


                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);
        }
Exemple #6
0
        public DataTable ProductionRecordSelect(ProductionRecordBLL u)
        {
            //static methodd to connect database
            SqlConnection conn = new SqlConnection(myconnstrng);
            //to hold the data from database
            DataTable dt = new DataTable();

            try
            {
                //sql query to get data from database
                String sql = @"SELECT * FROM tbl_production_record 
                                INNER JOIN tbl_plan 
                                ON tbl_plan.plan_id = tbl_production_record.plan_id WHERE tbl_production_record.sheet_id = @sheet_id";

                //INNER JOIN tbl_production_meter_reading  ON tbl_production_record.sheet_id = tbl_production_meter_reading.sheet_id
                //ORDER BY tbl_plan.machine_id ASC, tbl_plan.production_start_date ASC, tbl_plan.production_End_date ASC, tbl_production_record.sheet_id ASC
                //for executing command
                SqlCommand cmd = new SqlCommand(sql, conn);
                //getting data from database
                SqlDataAdapter adapter = new SqlDataAdapter(cmd);

                cmd.Parameters.AddWithValue("@sheet_id", u.sheet_id);

                //database connection open
                conn.Open();
                //fill data in our database
                adapter.Fill(dt);
            }
            catch (Exception ex)
            {
                //throw message if any error occurs
                Module.Tool tool = new Module.Tool();
                tool.saveToText(ex);
            }
            finally
            {
                //closing connection
                conn.Close();
            }
            return(dt);
        }
Exemple #7
0
        public bool DeleteMeterData(ProductionRecordBLL u)
        {
            bool          isSuccess = false;
            SqlConnection conn      = new SqlConnection(myconnstrng);

            try
            {
                String     sql = "DELETE FROM tbl_production_meter_reading WHERE sheet_id=@sheet_id";
                SqlCommand cmd = new SqlCommand(sql, conn);

                cmd.Parameters.AddWithValue("@sheet_id", u.sheet_id);

                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);
        }
Exemple #8
0
        public bool ProductionRecordUpdate(ProductionRecordBLL u)
        {
            bool isSuccess = false;

            u.active = true;
            SqlConnection conn = new SqlConnection(myconnstrng);

            try
            {
                String sql = @"UPDATE tbl_production_record 
                            SET "
                             + PlanID + "=@plan_id,"
                             + ProDate + "=@production_date,"
                             + Shift + "=@shift,"
                             + ProLotNo + "=@production_lot_no,"
                             + RawMatLotNo + "=@raw_mat_lot_no,"
                             + ColorMatLotNo + "=@color_mat_lot_no,"
                             + MeterStart + "=@meter_start,"
                             + MeterEnd + "=@meter_end,"
                             + LastShiftBalance + "=@last_shift_balance,"
                             + CurrentShiftBalance + "=@current_shift_balance,"
                             + FullBox + "=@full_box,"
                             + TotalProduced + "=@total_produced,"
                             + TotalReject + "=@total_reject,"
                             + Active + "=@active,"
                             + PackagingCode + "=@packaging_code,"
                             + PackagingQty + "=@packaging_qty,"
                             + ParentCode + "=@parent_code,"
                             + Note + "=@note,"
                             + directIn + "=@directIn,"
                             + directOut + "=@directOut,"
                             + UpdatedDate + "=@updated_date,"
                             + UpdatedBy + "=@updated_by" +
                             " WHERE sheet_id=@sheet_id";

                SqlCommand cmd = new SqlCommand(sql, conn);

                cmd.Parameters.AddWithValue("@sheet_id", u.sheet_id);
                cmd.Parameters.AddWithValue("@plan_id", u.plan_id);
                cmd.Parameters.AddWithValue("@production_date", u.production_date);
                cmd.Parameters.AddWithValue("@shift", u.shift);
                cmd.Parameters.AddWithValue("@production_lot_no", u.production_lot_no);
                cmd.Parameters.AddWithValue("@raw_mat_lot_no", u.raw_mat_lot_no);
                cmd.Parameters.AddWithValue("@color_mat_lot_no", u.color_mat_lot_no);
                cmd.Parameters.AddWithValue("@meter_start", u.meter_start);
                cmd.Parameters.AddWithValue("@meter_end", u.meter_end);
                cmd.Parameters.AddWithValue("@last_shift_balance", u.last_shift_balance);
                cmd.Parameters.AddWithValue("@current_shift_balance", u.current_shift_balance);
                cmd.Parameters.AddWithValue("@full_box", u.full_box);
                cmd.Parameters.AddWithValue("@total_produced", u.total_produced);
                cmd.Parameters.AddWithValue("@total_reject", u.total_reject);
                cmd.Parameters.AddWithValue("@updated_date", u.updated_date);
                cmd.Parameters.AddWithValue("@updated_by", u.updated_by);
                cmd.Parameters.AddWithValue("@active", u.active);
                cmd.Parameters.AddWithValue("@packaging_code", u.packaging_code);
                cmd.Parameters.AddWithValue("@packaging_qty", u.packaging_qty);
                cmd.Parameters.AddWithValue("@parent_code", u.parent_code);
                cmd.Parameters.AddWithValue("@note", u.note);
                cmd.Parameters.AddWithValue("@directIn", u.directIn);
                cmd.Parameters.AddWithValue("@directOut", u.directOut);

                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);
        }