コード例 #1
0
    public static bool Update(dbo_LoginHistoryClass newdbo_LoginHistoryClass)
    {
        SqlConnection connection      = SAMDataClass.GetConnection();
        string        updateProcedure = "[LoginHistoryUpdate]";
        SqlCommand    updateCommand   = new SqlCommand(updateProcedure, connection);

        updateCommand.CommandType = CommandType.StoredProcedure;
        if (newdbo_LoginHistoryClass.User_ID != null)
        {
            updateCommand.Parameters.AddWithValue("@NewUser_ID", newdbo_LoginHistoryClass.User_ID);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@NewUser_ID", DBNull.Value);
        }
        if (newdbo_LoginHistoryClass.Login_Time.HasValue == true)
        {
            updateCommand.Parameters.AddWithValue("@NewLogin_Time", newdbo_LoginHistoryClass.Login_Time);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@NewLogin_Time", DBNull.Value);
        }
        if (newdbo_LoginHistoryClass != null)
        {
            updateCommand.Parameters.AddWithValue("@NewStatus", newdbo_LoginHistoryClass.Status);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@NewStatus", DBNull.Value);
        }



        updateCommand.Parameters.Add("@ReturnValue", System.Data.SqlDbType.Int);
        updateCommand.Parameters["@ReturnValue"].Direction = ParameterDirection.Output;
        try
        {
            connection.Open();
            updateCommand.ExecuteNonQuery();
            int count = System.Convert.ToInt32(updateCommand.Parameters["@ReturnValue"].Value);
            if (count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        catch (SqlException ex)
        {
            logger.Error(ex.Message);
            return(false);
        }
        finally
        {
            connection.Close();
        }
    }
コード例 #2
0
    public static bool Add(dbo_OrderAndDeliveryCycleClass clsdbo_OrderAndDeliveryCycle, String Created_By)
    {
        SqlConnection connection      = SAMDataClass.GetConnection();
        string        insertProcedure = "OrderAndDeliveryCycleInsert";
        SqlCommand    insertCommand   = new SqlCommand(insertProcedure, connection);

        insertCommand.CommandType = CommandType.StoredProcedure;
        if (clsdbo_OrderAndDeliveryCycle.Order_Cycle_ID != null)
        {
            insertCommand.Parameters.AddWithValue("@Order_Cycle_ID", clsdbo_OrderAndDeliveryCycle.Order_Cycle_ID);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@Order_Cycle_ID", DBNull.Value);
        }
        if (clsdbo_OrderAndDeliveryCycle.Order_Cycle_Name != null)
        {
            insertCommand.Parameters.AddWithValue("@Order_Cycle_Name", clsdbo_OrderAndDeliveryCycle.Order_Cycle_Name);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@Order_Cycle_Name", DBNull.Value);
        }
        if (Created_By != null)
        {
            insertCommand.Parameters.AddWithValue("@Created_By", Created_By);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@Created_By", DBNull.Value);
        }



        insertCommand.Parameters.Add("@ReturnValue", System.Data.SqlDbType.Int);
        insertCommand.Parameters["@ReturnValue"].Direction = ParameterDirection.Output;
        try
        {
            connection.Open();
            insertCommand.ExecuteNonQuery();
            int count = System.Convert.ToInt32(insertCommand.Parameters["@ReturnValue"].Value);
            if (count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        catch (SqlException ex)
        {
            logger.Error(ex.Message);
            return(false);
        }
        finally
        {
            connection.Close();
        }
    }
コード例 #3
0
    public static String Customer_ID(string CV_Code)
    {
        string now   = GetNow();
        string year  = now.Substring(0, 2);
        string month = now.Substring(2, 2);
        string date  = now.Substring(4, 2);
        string id    = string.Empty;


        SqlConnection connection      = SAMDataClass.GetConnection();
        string        selectProcedure = "GET_ID";
        SqlCommand    selectCommand   = new SqlCommand(selectProcedure, connection);

        selectCommand.CommandType = CommandType.StoredProcedure;

        selectCommand.Parameters.AddWithValue("@Year", year);
        selectCommand.Parameters.AddWithValue("@Month", month);
        selectCommand.Parameters.AddWithValue("@Day", date);

        selectCommand.Parameters.AddWithValue("@Naming", "Customer_ID");
        selectCommand.Parameters.AddWithValue("@CV_Code", CV_Code);


        try
        {
            connection.Open();
            SqlDataReader reader
                = selectCommand.ExecuteReader(CommandBehavior.SingleRow);
            if (reader.Read())
            {
                id = reader["ID"] is DBNull ? "0" : reader["ID"].ToString();
            }
            else
            {
                id = "0";
            }
            reader.Close();
        }
        catch (SqlException ex)
        {
            //return clsdbo_OrderAndDeliveryCycle;
        }
        finally
        {
            connection.Close();
        }



        int index = int.Parse(id) + 1;



        string _id = string.Empty;

        _id = CV_Code + index.ToString("0000");;


        return(_id);
    }
コード例 #4
0
    public static dbo_DepositClass SumNetSalesBySPID(String User_ID)
    {
        dbo_DepositClass clsdbo_Deposit  = new dbo_DepositClass();
        SqlConnection    connection      = SAMDataClass.GetConnection();
        string           selectProcedure = "[DepositSumNetSalesBySP]";
        SqlCommand       selectCommand   = new SqlCommand(selectProcedure, connection);

        selectCommand.CommandType = CommandType.StoredProcedure;
        selectCommand.Parameters.AddWithValue("@User_ID", User_ID);
        try
        {
            connection.Open();
            SqlDataReader reader
                = selectCommand.ExecuteReader(CommandBehavior.SingleRow);
            if (reader.Read())
            {
                clsdbo_Deposit.Net_Sales_Amount = reader["Net_Sales_Amount"] is DBNull ? null : (Decimal?)reader["Net_Sales_Amount"];
            }
            else
            {
                clsdbo_Deposit = null;
            }
            reader.Close();
        }
        catch (SqlException ex)
        {
            logger.Error(ex.Message);
            return(clsdbo_Deposit);
        }
        finally
        {
            connection.Close();
        }
        return(clsdbo_Deposit);
    }
コード例 #5
0
    public static Boolean DeleteItemValue_New(string itemValueID)
    {
        SqlConnection connection      = SAMDataClass.GetConnection();
        string        insertProcedure = "DeleteItemValue";
        SqlCommand    insertCommand   = new SqlCommand(insertProcedure, connection);

        insertCommand.CommandType = CommandType.StoredProcedure;
        insertCommand.Parameters.AddWithValue("@Mode", "DelItemValue");
        insertCommand.Parameters.AddWithValue("@Item_Value_ID", itemValueID);
        try
        {
            connection.Open();
            int count = insertCommand.ExecuteNonQuery();
            if (count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        catch (SqlException ex)
        {
            logger.Error(ex.Message);
            return(false);
        }
        finally
        {
            connection.Close();
        }
    }
コード例 #6
0
    public static Boolean UpdateItem_New(dbo_ItemClass clsItem, string userName)
    {
        SqlConnection connection      = SAMDataClass.GetConnection();
        string        insertProcedure = "UpdateItemValue";
        SqlCommand    insertCommand   = new SqlCommand(insertProcedure, connection);

        insertCommand.CommandType = CommandType.StoredProcedure;
        insertCommand.Parameters.AddWithValue("@Mode", "UpdItem");
        insertCommand.Parameters.AddWithValue("@Item_ID", clsItem.Item_ID);
        insertCommand.Parameters.AddWithValue("@UpdateBY", userName);
        insertCommand.Parameters.AddWithValue("@UpdateParam", clsItem.Item_Name);
        try
        {
            connection.Open();
            int count = insertCommand.ExecuteNonQuery();
            if (count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        catch (SqlException ex)
        {
            logger.Error(ex.Message);
            return(false);
        }
        finally
        {
            connection.Close();
        }
    }
コード例 #7
0
    public static DataTable SelectAll()
    {
        logger.Info(System.Web.HttpContext.Current.Request.Cookies["User_ID"].Value == null ? string.Empty : System.Web.HttpContext.Current.Request.Cookies["User_ID"].Value + " " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString() + " " + System.Reflection.MethodBase.GetCurrentMethod().Name);
        SqlConnection connection      = SAMDataClass.GetConnection();
        string        selectProcedure = "[dbo].[CommissionRequisitionDtlSelectAll]";
        SqlCommand    selectCommand   = new SqlCommand(selectProcedure, connection);

        selectCommand.CommandType = CommandType.StoredProcedure;
        DataTable dt = new DataTable();

        try
        {
            connection.Open();
            SqlDataReader reader = selectCommand.ExecuteReader();
            if (reader.HasRows)
            {
                dt.Load(reader);
            }
            reader.Close();
        }
        catch (SqlException ex)
        {
            return(dt);
        }
        finally
        {
            connection.Close();
        }
        return(dt);
    }
コード例 #8
0
    public static List <dbo_CommissionRequisitionDtlClass> Search(String CV_Code)
    {
        logger.Info(System.Web.HttpContext.Current.Request.Cookies["User_ID"].Value == null ? string.Empty : System.Web.HttpContext.Current.Request.Cookies["User_ID"].Value + " " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString() + " " + System.Reflection.MethodBase.GetCurrentMethod().Name);
        SqlConnection connection      = SAMDataClass.GetConnection();
        string        selectProcedure = "[CommissionRequisitionDtlSearch]";
        SqlCommand    selectCommand   = new SqlCommand(selectProcedure, connection);

        selectCommand.CommandType = CommandType.StoredProcedure;


        if (!string.IsNullOrEmpty(CV_Code))
        {
            selectCommand.Parameters.AddWithValue("@CV_Code", CV_Code);
        }
        else
        {
            selectCommand.Parameters.AddWithValue("@CV_Code", DBNull.Value);
        }

        List <dbo_CommissionRequisitionDtlClass> item = new List <dbo_CommissionRequisitionDtlClass>();
        DataTable dt = new DataTable();

        try
        {
            connection.Open();
            SqlDataReader reader1 = selectCommand.ExecuteReader();
            if (reader1.HasRows)
            {
                dt.Load(reader1);
                foreach (DataRow reader in dt.Rows)
                {
                    item.Add(new dbo_CommissionRequisitionDtlClass()
                    {
                        // Commission_requisition_no = reader["Commission_requisition_no"] is DBNull ? null : reader["Commission_requisition_no"].ToString(),

                        Clearing_No = reader["Clearing_No"] is DBNull ? null : reader["Clearing_No"].ToString(),


                        //Commission = reader["Commission"] is DBNull ? null : (Decimal?)reader["Commission"],
                        //Requisition_Amount = reader["Requisition_Amount"] is DBNull ? null : (Decimal?)reader["Requisition_Amount"],
                    });
                }
            }
            reader1.Close();
        }
        catch (SqlException ex)
        {
            logger.Error(ex.Message);
            return(item);
        }
        catch (Exception ex)
        {
            logger.Error(ex.Message);
        }
        finally
        {
            connection.Close();
        }
        return(item);
    }
コード例 #9
0
    public static bool DeleteByRefNo(String Ref_No)
    {
        SqlConnection connection      = SAMDataClass.GetConnection();
        string        deleteProcedure = "[StockMovementDeleteByRefNo]";
        SqlCommand    deleteCommand   = new SqlCommand(deleteProcedure, connection);

        deleteCommand.CommandType = CommandType.StoredProcedure;
        deleteCommand.Parameters.AddWithValue("@OldRef_No", Ref_No);


        deleteCommand.Parameters.Add("@ReturnValue", System.Data.SqlDbType.Int);
        deleteCommand.Parameters["@ReturnValue"].Direction = ParameterDirection.Output;
        try
        {
            connection.Open();
            deleteCommand.ExecuteNonQuery();
            int count = System.Convert.ToInt32(deleteCommand.Parameters["@ReturnValue"].Value);
            if (count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        catch (SqlException)
        {
            return(false);
        }
        finally
        {
            connection.Close();
        }
    }
コード例 #10
0
    public static dbo_RevenueExpenseClass SumBySP(string User_ID)
    {
        dbo_RevenueExpenseClass clsdbo_RevenueExpense = new dbo_RevenueExpenseClass();
        SqlConnection           connection            = SAMDataClass.GetConnection();
        string     selectProcedure = "[dbo].[RevenueExpenseSumBySP]";
        SqlCommand selectCommand   = new SqlCommand(selectProcedure, connection);

        selectCommand.CommandType = CommandType.StoredProcedure;
        selectCommand.Parameters.AddWithValue("@User_ID", User_ID);
        try
        {
            connection.Open();
            SqlDataReader reader
                = selectCommand.ExecuteReader(CommandBehavior.SingleRow);
            if (reader.Read())
            {
                clsdbo_RevenueExpense.Amount = reader["Amount"] is DBNull ? null : (Decimal?)reader["Amount"];
            }
            else
            {
                clsdbo_RevenueExpense = null;
            }
            reader.Close();
        }
        catch (SqlException)
        {
            return(clsdbo_RevenueExpense);
        }
        finally
        {
            connection.Close();
        }
        return(clsdbo_RevenueExpense);
    }
コード例 #11
0
    public static List <dbo_InstallationClass> Search(string User_ID)
    {
        logger.Info(System.Web.HttpContext.Current.Request.Cookies["User_ID"].Value + " " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString() + " " + System.Reflection.MethodBase.GetCurrentMethod().Name);

        SqlConnection connection      = SAMDataClass.GetConnection();
        string        selectProcedure = "[InstallationSearch]";
        SqlCommand    selectCommand   = new SqlCommand(selectProcedure, connection);

        selectCommand.CommandType = CommandType.StoredProcedure;
        if (!string.IsNullOrEmpty(User_ID))
        {
            selectCommand.Parameters.AddWithValue("@User_ID", User_ID);
        }
        else
        {
            selectCommand.Parameters.AddWithValue("@User_ID", DBNull.Value);
        }

        List <dbo_InstallationClass> item = new List <dbo_InstallationClass>();
        DataTable dt = new DataTable();

        try
        {
            connection.Open();
            SqlDataReader reader1 = selectCommand.ExecuteReader();
            if (reader1.HasRows)
            {
                dt.Load(reader1);


                foreach (DataRow reader in dt.Rows)
                {
                    item.Add(new dbo_InstallationClass()
                    {
                        Installation_ID     = reader["Installation_ID"] is DBNull ? null : reader["Installation_ID"].ToString(),
                        User_ID             = reader["User_ID"] is DBNull ? null : reader["User_ID"].ToString(),
                        Installation_Detail = reader["Installation_Detail"] is DBNull ? null : reader["Installation_Detail"].ToString(),
                        Installation_Type   = reader["Installation_Type"] is DBNull ? null : reader["Installation_Type"].ToString(),
                        Description         = reader["Description"] is DBNull ? null : reader["Description"].ToString(),
                        Installation_Amount = reader["Installation_Amount"] is DBNull ? null : (Decimal?)reader["Installation_Amount"],
                        Transaction_Date    = reader["Transaction_Date"] is DBNull ? null : (DateTime?)reader["Transaction_Date"],
                        Due_Date            = reader["Due_Date"] is DBNull ? null : (DateTime?)reader["Due_Date"],
                        Balance_Amount      = reader["Balance_Amount"] is DBNull ? null : (Decimal?)reader["Balance_Amount"],
                        Payment_Amount      = reader["Payment_Amount"] is DBNull ? null : (Decimal?)reader["Payment_Amount"]
                    });
                }
            }
            reader1.Close();
        }
        catch (SqlException ex)
        {
            logger.Error(ex.Message);
            return(item);
        }
        finally
        {
            connection.Close();
        }
        return(item);
    }
コード例 #12
0
    public static DataTable SelectAll()
    {
        SqlConnection connection      = SAMDataClass.GetConnection();
        string        selectProcedure = "[dbo].[OrderingDetailSelectAll]";
        SqlCommand    selectCommand   = new SqlCommand(selectProcedure, connection);

        selectCommand.CommandType = CommandType.StoredProcedure;
        DataTable dt = new DataTable();

        try
        {
            connection.Open();
            SqlDataReader reader = selectCommand.ExecuteReader();
            if (reader.HasRows)
            {
                dt.Load(reader);
            }
            reader.Close();
        }
        catch (SqlException ex)
        {
            logger.Error(ex.Message);
            return(dt);
        }
        finally
        {
            connection.Close();
        }
        return(dt);
    }
コード例 #13
0
    public static List <dbo_SubsidyClass> Search(String Clearing_No)
    {
        SqlConnection connection      = SAMDataClass.GetConnection();
        string        selectProcedure = "[SubsidySearch]";
        SqlCommand    selectCommand   = new SqlCommand(selectProcedure, connection);

        selectCommand.CommandType = CommandType.StoredProcedure;



        if (!string.IsNullOrEmpty(Clearing_No))
        {
            selectCommand.Parameters.AddWithValue("@Clearing_No", Clearing_No);
        }
        else
        {
            selectCommand.Parameters.AddWithValue("@Clearing_No", DBNull.Value);
        }


        List <dbo_SubsidyClass> item = new List <dbo_SubsidyClass>();

        DataTable dt = new DataTable();

        try
        {
            connection.Open();
            SqlDataReader reader1 = selectCommand.ExecuteReader();
            if (reader1.HasRows)
            {
                dt.Load(reader1);
                foreach (DataRow reader in dt.Rows)
                {
                    item.Add(new dbo_SubsidyClass()
                    {
                        Subsidy_ID     = reader["Subsidy_ID"] is DBNull ? null : reader["Subsidy_ID"].ToString(),
                        Clearing_No    = reader["Clearing_No"] is DBNull ? null : reader["Clearing_No"].ToString(),
                        Subsidy_Detail = reader["Subsidy_Detail"] is DBNull ? null : reader["Subsidy_Detail"].ToString(),
                        Subsidy_Amount = reader["Subsidy_Amount"] is DBNull ? null : (Decimal?)reader["Subsidy_Amount"],
                        Account_Code   = reader["Account_Code"] is DBNull ? null : reader["Account_Code"].ToString()
                    });
                }
            }
            reader1.Close();
        }
        catch (SqlException ex)
        {
            return(item);
        }
        catch (Exception ex)
        {
        }
        finally
        {
            connection.Close();
        }
        return(item);
    }
コード例 #14
0
    public static List <dbo_OrderAndDeliveryCycleValueClass> GetWindowTime(string CV_Code)
    {
        logger.Info(HttpContext.Current.Request.Cookies["User_ID"].Value + " " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString() + " " + System.Reflection.MethodBase.GetCurrentMethod().Name);

        SqlConnection connection      = SAMDataClass.GetConnection();
        string        selectProcedure = "GetWindowTime";
        SqlCommand    selectCommand   = new SqlCommand(selectProcedure, connection);

        selectCommand.CommandType = CommandType.StoredProcedure;


        if (!string.IsNullOrEmpty(CV_Code))
        {
            selectCommand.Parameters.AddWithValue("@CV_Code", CV_Code);
        }
        else
        {
            selectCommand.Parameters.AddWithValue("@CV_Code", DBNull.Value);
        }


        List <dbo_OrderAndDeliveryCycleValueClass> item = new List <dbo_OrderAndDeliveryCycleValueClass>();


        DataTable dt = new DataTable();

        try
        {
            connection.Open();
            SqlDataReader reader1 = selectCommand.ExecuteReader();
            if (reader1.HasRows)
            {
                dt.Load(reader1);
                foreach (DataRow reader in dt.Rows)
                {
                    item.Add(new dbo_OrderAndDeliveryCycleValueClass()
                    {
                        Order_Cycle_ID   = reader["Order_Cycle_ID"] is DBNull ? null : reader["Order_Cycle_ID"].ToString(),
                        CV_CODE          = reader["CV_CODE"] is DBNull ? null : reader["CV_CODE"].ToString(),
                        Order_Cycle_Date = reader["Order_Cycle_Date"] is DBNull ? null : reader["Order_Cycle_Date"].ToString(),
                        Order_Cycle_Hour = reader["Order_Cycle_Hour"] is DBNull ? null : reader["Order_Cycle_Hour"].ToString(),
                        WindowTime       = reader["WindowTime"] is DBNull ? null : reader["WindowTime"].ToString()
                    });
                }
            }
            reader1.Close();
        }
        catch (SqlException ex)
        {
            logger.Error(ex.Message);
            return(item);
        }
        finally
        {
            connection.Close();
        }
        return(item);
    }
コード例 #15
0
    public static Dictionary <string, string> GetAssignPriceGroupSP(String Price_Group_Id, String CV_Code)
    {
        Dictionary <string, string> unit = new Dictionary <string, string>();
        SqlConnection connection         = SAMDataClass.GetConnection();
        string        selectProcedure    = "[GetAssignPriceGroupSP]";

        SqlCommand selectCommand = new SqlCommand(selectProcedure, connection);

        selectCommand.CommandType = CommandType.StoredProcedure;


        if (!string.IsNullOrEmpty(Price_Group_Id))
        {
            selectCommand.Parameters.AddWithValue("@Price_Group_ID", Price_Group_Id);
        }
        else
        {
            selectCommand.Parameters.AddWithValue("@Price_Group_ID", DBNull.Value);
        }
        if (!string.IsNullOrEmpty(CV_Code))
        {
            selectCommand.Parameters.AddWithValue("@CV_Code", CV_Code);
        }
        else
        {
            selectCommand.Parameters.AddWithValue("@CV_Code", DBNull.Value);
        }

        DataTable dt = new DataTable();

        try
        {
            connection.Open();
            SqlDataReader reader = selectCommand.ExecuteReader();
            if (reader.HasRows)
            {
                dt.Load(reader);

                // unit.Add(string.Empty, "==ระบุ==");

                foreach (DataRow row in dt.Rows)
                {
                    unit.Add(row["User_ID"].ToString(), row["FullName"].ToString());
                }
            }
            reader.Close();
        }
        catch (SqlException ex)
        {
            logger.Error(ex.Message);
            return(unit);
        }
        finally
        {
            connection.Close();
        }
        return(unit);
    }
コード例 #16
0
    public static List <dbo_OtherRequisitionDetailClass> Search(String Requisition_No)
    {
        SqlConnection connection      = SAMDataClass.GetConnection();
        string        selectProcedure = "[OtherRequisitionDetailSearchbyRequistionNo]";
        SqlCommand    selectCommand   = new SqlCommand(selectProcedure, connection);

        selectCommand.CommandType = CommandType.StoredProcedure;


        if (!string.IsNullOrEmpty(Requisition_No))
        {
            selectCommand.Parameters.AddWithValue("@Requisition_No", Requisition_No);
        }
        else
        {
            selectCommand.Parameters.AddWithValue("@Requisition_No", DBNull.Value);
        }



        List <dbo_OtherRequisitionDetailClass> item = new List <dbo_OtherRequisitionDetailClass>();
        DataTable dt = new DataTable();

        try
        {
            connection.Open();
            SqlDataReader reader1 = selectCommand.ExecuteReader();
            if (reader1.HasRows)
            {
                dt.Load(reader1);

                foreach (DataRow reader in dt.Rows)
                {
                    item.Add(new dbo_OtherRequisitionDetailClass()
                    {
                        Other_Requisition_Detail_ID = reader["Other_Requisition_Detail_ID"] is DBNull ? null : reader["Other_Requisition_Detail_ID"].ToString(),
                        Requisition_No  = reader["Requisition_No"] is DBNull ? null : reader["Requisition_No"].ToString(),
                        Product_ID      = reader["Product_ID"] is DBNull ? null : reader["Product_ID"].ToString(),
                        Price           = reader["Price"] is DBNull ? null : (Decimal?)reader["Price"],
                        Vat             = reader["Vat"] is DBNull ? null : (Byte?)reader["Vat"],
                        Stock_on_Hand   = reader["Stock_on_Hand"] is DBNull ? null : (Int32?)reader["Stock_on_Hand"],
                        Requisition_Qty = reader["Requisition_Qty"] is DBNull ? null : (Int16?)reader["Requisition_Qty"]
                    });
                }
            }
            reader1.Close();
        }
        catch (SqlException ex)
        {
            logger.Error(ex.Message);
            return(item);
        }
        finally
        {
            connection.Close();
        }
        return(item);
    }
コード例 #17
0
    public static bool Delete(dbo_TambolClass clsdbo_Tambol)
    {
        SqlConnection connection      = SAMDataClass.GetConnection();
        string        deleteProcedure = "[dbo].[TambolDelete]";
        SqlCommand    deleteCommand   = new SqlCommand(deleteProcedure, connection);

        deleteCommand.CommandType = CommandType.StoredProcedure;
        if (clsdbo_Tambol.Sub_district != null)
        {
            deleteCommand.Parameters.AddWithValue("@OldSub_district", clsdbo_Tambol.Sub_district);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldSub_district", DBNull.Value);
        }
        if (clsdbo_Tambol.District != null)
        {
            deleteCommand.Parameters.AddWithValue("@OldDistrict", clsdbo_Tambol.District);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldDistrict", DBNull.Value);
        }
        if (clsdbo_Tambol.Province != null)
        {
            deleteCommand.Parameters.AddWithValue("@OldProvince", clsdbo_Tambol.Province);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldProvince", DBNull.Value);
        }
        deleteCommand.Parameters.AddWithValue("@OldID", clsdbo_Tambol.ID);
        deleteCommand.Parameters.Add("@ReturnValue", System.Data.SqlDbType.Int);
        deleteCommand.Parameters["@ReturnValue"].Direction = ParameterDirection.Output;
        try
        {
            connection.Open();
            deleteCommand.ExecuteNonQuery();
            int count = System.Convert.ToInt32(deleteCommand.Parameters["@ReturnValue"].Value);
            if (count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        catch (SqlException ex)
        {
            return(false);
        }
        finally
        {
            connection.Close();
        }
    }
コード例 #18
0
    public static dbo_ProductListClass Select_Record(string Product_List_ID)
    {
        dbo_ProductListClass clsdbo_ProductList = new dbo_ProductListClass();
        SqlConnection        connection         = SAMDataClass.GetConnection();
        string     selectProcedure = "ProductListSelect";
        SqlCommand selectCommand   = new SqlCommand(selectProcedure, connection);

        selectCommand.CommandType = CommandType.StoredProcedure;
        selectCommand.Parameters.AddWithValue("@Product_List_ID", Product_List_ID);
        try
        {
            connection.Open();
            SqlDataReader reader
                = selectCommand.ExecuteReader(CommandBehavior.SingleRow);
            if (reader.Read())
            {
                clsdbo_ProductList.Product_List_ID = reader["Product_List_ID"] is DBNull ? null : reader["Product_List_ID"].ToString();
                clsdbo_ProductList.Price_Group_ID  = reader["Price_Group_ID"] is DBNull ? null : reader["Price_Group_ID"].ToString();
                clsdbo_ProductList.Product_ID      = reader["Product_ID"] is DBNull ? null : reader["Product_ID"].ToString();
                clsdbo_ProductList.Product_Name    = reader["Product_Name"] is DBNull ? null : reader["Product_Name"].ToString();
                clsdbo_ProductList.CP_Meiji_Price  = reader["CP_Meiji_Price"] is DBNull ? null : (Decimal?)reader["CP_Meiji_Price"];
                clsdbo_ProductList.Price           = reader["Price"] is DBNull ? null : (Decimal?)reader["Price"];
                clsdbo_ProductList.Point           = reader["Point"] is DBNull ? null : (Byte?)reader["Point"];


                //clsdbo_ProductList.Exclude_Vat = reader["Exclude_Vat"] is DBNull ? null : (Boolean?)reader["Exclude_Vat"];


                clsdbo_ProductList.Vat = reader["Vat"] is DBNull ? null : (Byte?)reader["Vat"];
                clsdbo_ProductList.Start_Effective_Date   = reader["Start_Effective_Date"] is DBNull ? null : (DateTime?)reader["Start_Effective_Date"];
                clsdbo_ProductList.End_Effective_Date     = reader["End_Effective_Date"] is DBNull ? null : (DateTime?)reader["End_Effective_Date"];
                clsdbo_ProductList.Product_Effective_Date = reader["Product_Effective_Date"] is DBNull ? null : (DateTime?)reader["Product_Effective_Date"];
                clsdbo_ProductList.Agent_Price            = reader["Agent_Price"] is DBNull ? null : (Decimal?)reader["Agent_Price"];
                clsdbo_ProductList.SP_Price = reader["SP_Price"] is DBNull ? null : (Decimal?)reader["SP_Price"];



                clsdbo_ProductList.CV_CODE          = reader["CV_CODE"] is DBNull ? null : reader["CV_CODE"].ToString();
                clsdbo_ProductList.Price_Group_Type = reader["Price_Group_Type"] is DBNull ? null : reader["Price_Group_Type"].ToString();
            }
            else
            {
                clsdbo_ProductList = null;
            }
            reader.Close();
        }
        catch (SqlException ex)
        {
            logger.Error(ex.Message);
            return(clsdbo_ProductList);
        }
        finally
        {
            connection.Close();
        }
        return(clsdbo_ProductList);
    }
コード例 #19
0
    public static bool Delete(string Assign_To)
    {
        logger.Info(HttpContext.Current.Request.Cookies["User_ID"].Value + " " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString() + " " + System.Reflection.MethodBase.GetCurrentMethod().Name);

        SqlConnection connection      = SAMDataClass.GetConnection();
        string        deleteProcedure = "[PriceGroupAssignmentDelete]";
        SqlCommand    deleteCommand   = new SqlCommand(deleteProcedure, connection);

        deleteCommand.CommandType = CommandType.StoredProcedure;


        //if (clsdbo_PriceGroupAssignment.Price_Group_ID != null)
        //{
        //    deleteCommand.Parameters.AddWithValue("@OldPrice_Group_ID", clsdbo_PriceGroupAssignment.Price_Group_ID);
        //}
        //else
        //{
        //    deleteCommand.Parameters.AddWithValue("@OldPrice_Group_ID", DBNull.Value);
        //}


        if (Assign_To != null)
        {
            deleteCommand.Parameters.AddWithValue("@OldAssign_To", Assign_To);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldAssign_To", DBNull.Value);
        }


        deleteCommand.Parameters.Add("@ReturnValue", System.Data.SqlDbType.Int);
        deleteCommand.Parameters["@ReturnValue"].Direction = ParameterDirection.Output;
        try
        {
            connection.Open();
            deleteCommand.ExecuteNonQuery();
            int count = System.Convert.ToInt32(deleteCommand.Parameters["@ReturnValue"].Value);
            if (count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        catch (SqlException ex)
        {
            logger.Error(ex.Message);
            return(false);
        }
        finally
        {
            connection.Close();
        }
    }
コード例 #20
0
    public static bool Add(dbo_LoginHistoryClass clsdbo_LoginHistory)
    {
        SqlConnection connection      = SAMDataClass.GetConnection();
        string        insertProcedure = "[dbo].[LoginHistoryInsert]";
        SqlCommand    insertCommand   = new SqlCommand(insertProcedure, connection);

        insertCommand.CommandType = CommandType.StoredProcedure;
        if (clsdbo_LoginHistory.User_ID != null)
        {
            insertCommand.Parameters.AddWithValue("@User_ID", clsdbo_LoginHistory.User_ID);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@User_ID", DBNull.Value);
        }
        if (clsdbo_LoginHistory.Login_Time.HasValue == true)
        {
            insertCommand.Parameters.AddWithValue("@Login_Time", clsdbo_LoginHistory.Login_Time);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@Login_Time", DBNull.Value);
        }
        if (clsdbo_LoginHistory != null)
        {
            insertCommand.Parameters.AddWithValue("@Status", clsdbo_LoginHistory.Status);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@Status", DBNull.Value);
        }
        insertCommand.Parameters.Add("@ReturnValue", System.Data.SqlDbType.Int);
        insertCommand.Parameters["@ReturnValue"].Direction = ParameterDirection.Output;
        try
        {
            connection.Open();
            insertCommand.ExecuteNonQuery();
            int count = System.Convert.ToInt32(insertCommand.Parameters["@ReturnValue"].Value);
            if (count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        catch (SqlException ex)
        {
            logger.Error(ex.Message);
            return(false);
        }
        finally
        {
            connection.Close();
        }
    }
コード例 #21
0
    public static bool Delete(dbo_PasswordHistoryClass clsdbo_PasswordHistory)
    {
        SqlConnection connection      = SAMDataClass.GetConnection();
        string        deleteProcedure = "[dbo].[PasswordHistoryDelete]";
        SqlCommand    deleteCommand   = new SqlCommand(deleteProcedure, connection);

        deleteCommand.CommandType = CommandType.StoredProcedure;
        if (clsdbo_PasswordHistory.User_ID != null)
        {
            deleteCommand.Parameters.AddWithValue("@OldUser_ID", clsdbo_PasswordHistory.User_ID);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldUser_ID", DBNull.Value);
        }
        if (clsdbo_PasswordHistory.Password != null)
        {
            deleteCommand.Parameters.AddWithValue("@OldPassword", clsdbo_PasswordHistory.Password);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldPassword", DBNull.Value);
        }
        if (clsdbo_PasswordHistory.Last_Password_Change_Or_Reset.HasValue == true)
        {
            deleteCommand.Parameters.AddWithValue("@OldLast_Password_Change_Or_Reset", clsdbo_PasswordHistory.Last_Password_Change_Or_Reset);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldLast_Password_Change_Or_Reset", DBNull.Value);
        }
        deleteCommand.Parameters.Add("@ReturnValue", System.Data.SqlDbType.Int);
        deleteCommand.Parameters["@ReturnValue"].Direction = ParameterDirection.Output;
        try
        {
            connection.Open();
            deleteCommand.ExecuteNonQuery();
            int count = System.Convert.ToInt32(deleteCommand.Parameters["@ReturnValue"].Value);
            if (count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        catch (SqlException ex)
        {
            logger.Error(ex.Message);
            return(false);
        }
        finally
        {
            connection.Close();
        }
    }
コード例 #22
0
    public static List <dbo_RequisitionClearingClass> SearchByReqNo(string Req_No)
    {
        logger.Info(HttpContext.Current.Request.Cookies["User_ID"].Value + " " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString() + " " + System.Reflection.MethodBase.GetCurrentMethod().Name);
        SqlConnection connection      = SAMDataClass.GetConnection();
        string        selectProcedure = "[RequisitionClearingSearchByReqNo]";
        SqlCommand    selectCommand   = new SqlCommand(selectProcedure, connection);

        selectCommand.CommandType = CommandType.StoredProcedure;

        if (!string.IsNullOrEmpty(Req_No))
        {
            selectCommand.Parameters.AddWithValue("@Requisition_No", Req_No);
        }
        else
        {
            selectCommand.Parameters.AddWithValue("@Requisition_No", DBNull.Value);
        }

        List <dbo_RequisitionClearingClass> item = new List <dbo_RequisitionClearingClass>();


        DataTable dt = new DataTable();

        try
        {
            connection.Open();
            SqlDataReader reader1 = selectCommand.ExecuteReader();
            if (reader1.HasRows)
            {
                dt.Load(reader1);

                foreach (DataRow reader in dt.Rows)
                {
                    item.Add(new dbo_RequisitionClearingClass()
                    {
                        Clearing_No = reader["Clearing_No"] is DBNull ? null : reader["Clearing_No"].ToString(),
                        //User_ID = reader["User_ID"] is DBNull ? null : reader["User_ID"].ToString(),
                        Status = reader["Status"] is DBNull ? null : reader["Status"].ToString(),
                        //Requisition_No = reader["Requisition_No"] is DBNull ? null : reader["Requisition_No"].ToString(),
                        //Requisition_Date = reader["Requisition_Date"] is DBNull ? null : (DateTime?)reader["Requisition_Date"],
                        //Clearing_Date = reader["Clearing_Date"] is DBNull ? null : (DateTime?)reader["Clearing_Date"]
                    });
                }
            }
            reader1.Close();
        }
        catch (SqlException ex)
        {
            logger.Error(ex.Message);
            return(item);
        }
        finally
        {
            connection.Close();
        }
        return(item);
    }
コード例 #23
0
    public static dbo_BillingClass Select_Record(String Billing_ID)
    {
        dbo_BillingClass clsdbo_Billing  = new dbo_BillingClass();
        SqlConnection    connection      = SAMDataClass.GetConnection();
        string           selectProcedure = "[BillingSelect]";
        SqlCommand       selectCommand   = new SqlCommand(selectProcedure, connection);

        selectCommand.CommandType = CommandType.StoredProcedure;
        selectCommand.Parameters.AddWithValue("@Billing_ID", Billing_ID);
        try
        {
            connection.Open();
            SqlDataReader reader
                = selectCommand.ExecuteReader(CommandBehavior.SingleRow);
            if (reader.Read())
            {
                clsdbo_Billing.Billing_ID         = reader["Billing_ID"] is DBNull ? null : reader["Billing_ID"].ToString();
                clsdbo_Billing.Billing_Type       = reader["Billing_Type"] is DBNull ? null : reader["Billing_Type"].ToString();
                clsdbo_Billing.Order_Type         = reader["Order_Type"] is DBNull ? null : reader["Order_Type"].ToString();
                clsdbo_Billing.CV_Number          = reader["CV_Number"] is DBNull ? null : reader["CV_Number"].ToString();
                clsdbo_Billing.Invoice_No         = reader["Invoice_No"] is DBNull ? null : reader["Invoice_No"].ToString();
                clsdbo_Billing.Invoice_Date       = reader["Invoice_Date"] is DBNull ? null : (DateTime?)reader["Invoice_Date"];
                clsdbo_Billing.PO_No              = reader["PO_No"] is DBNull ? null : reader["PO_No"].ToString();
                clsdbo_Billing.PO_Date            = reader["PO_Date"] is DBNull ? null : (DateTime?)reader["PO_Date"];
                clsdbo_Billing.Net_Value          = reader["Net_Value"] is DBNull ? null : (Decimal?)reader["Net_Value"];
                clsdbo_Billing.Vat                = reader["Vat"] is DBNull ? null : (Decimal?)reader["Vat"];
                clsdbo_Billing.Total              = reader["Total"] is DBNull ? null : (Decimal?)reader["Total"];
                clsdbo_Billing.Ref_Invoice_No     = reader["Ref_Invoice_No"] is DBNull ? null : reader["Ref_Invoice_No"].ToString();
                clsdbo_Billing.Invoice_Status     = reader["Invoice_Status"] is DBNull ? null : reader["Invoice_Status"].ToString();
                clsdbo_Billing.Created_Date       = reader["Created_Date"] is DBNull ? null : (DateTime?)reader["Created_Date"];
                clsdbo_Billing.Created_By         = reader["Created_By"] is DBNull ? null : reader["Created_By"].ToString();
                clsdbo_Billing.Last_Modified_Date = reader["Last_Modified_Date"] is DBNull ? null : (DateTime?)reader["Last_Modified_Date"];
                clsdbo_Billing.Last_Modified_By   = reader["Last_Modified_By"] is DBNull ? null : reader["Last_Modified_By"].ToString();
                clsdbo_Billing.Order_Status       = reader["Order_Status"] is DBNull ? null : reader["Order_Status"].ToString();
            }
            else
            {
                clsdbo_Billing = null;
            }
            reader.Close();
        }
        catch (SqlException ex)
        {
            logger.Error(ex.Message);
            return(clsdbo_Billing);
        }
        catch (Exception ex)
        {
            logger.Error(ex.Message);
        }
        finally
        {
            connection.Close();
        }
        return(clsdbo_Billing);
    }
コード例 #24
0
    public static bool Delete(dbo_ReadNewsClass clsdbo_ReadNews)
    {
        SqlConnection connection      = SAMDataClass.GetConnection();
        string        deleteProcedure = "[dbo].[ReadNewsDelete]";
        SqlCommand    deleteCommand   = new SqlCommand(deleteProcedure, connection);

        deleteCommand.CommandType = CommandType.StoredProcedure;
        if (clsdbo_ReadNews.News_ID != null)
        {
            deleteCommand.Parameters.AddWithValue("@OldNews_ID", clsdbo_ReadNews.News_ID);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldNews_ID", DBNull.Value);
        }
        if (clsdbo_ReadNews.User_ID != null)
        {
            deleteCommand.Parameters.AddWithValue("@OldUser_ID", clsdbo_ReadNews.User_ID);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldUser_ID", DBNull.Value);
        }
        if (clsdbo_ReadNews.Read_Date.HasValue == true)
        {
            deleteCommand.Parameters.AddWithValue("@OldRead_Date", clsdbo_ReadNews.Read_Date);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldRead_Date", DBNull.Value);
        }
        deleteCommand.Parameters.Add("@ReturnValue", System.Data.SqlDbType.Int);
        deleteCommand.Parameters["@ReturnValue"].Direction = ParameterDirection.Output;
        try
        {
            connection.Open();
            deleteCommand.ExecuteNonQuery();
            int count = System.Convert.ToInt32(deleteCommand.Parameters["@ReturnValue"].Value);
            if (count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        catch (SqlException)
        {
            return(false);
        }
        finally
        {
            connection.Close();
        }
    }
コード例 #25
0
    public static List <dbo_RolePermissionClass> Search(string Role_ID)
    {
        SqlConnection connection      = SAMDataClass.GetConnection();
        string        selectProcedure = "[dbo].[RolePermissionSearch]";
        SqlCommand    selectCommand   = new SqlCommand(selectProcedure, connection);

        selectCommand.CommandType = CommandType.StoredProcedure;

        if (!string.IsNullOrEmpty(Role_ID))
        {
            selectCommand.Parameters.AddWithValue("@Role_ID", Role_ID);
        }
        else
        {
            selectCommand.Parameters.AddWithValue("@Role_ID", DBNull.Value);
        }



        List <dbo_RolePermissionClass> item = new List <dbo_RolePermissionClass>();

        DataTable dt = new DataTable();

        try
        {
            connection.Open();
            SqlDataReader reader1 = selectCommand.ExecuteReader();
            if (reader1.HasRows)
            {
                dt.Load(reader1);

                foreach (DataRow reader in dt.Rows)
                {
                    item.Add(new dbo_RolePermissionClass()
                    {
                        Role_Permission_ID = reader["Role_Permission_ID"] is DBNull ? null : reader["Role_Permission_ID"].ToString()
                        ,
                        Role_ID = reader["Role_ID"] is DBNull ? null : reader["Role_ID"].ToString()
                        ,
                        Function_Name = reader["Function_Name"] is DBNull ? null : reader["Function_Name"].ToString()
                    });
                }
            }
            reader1.Close();
        }
        catch (SqlException ex)
        {
            logger.Error(ex.Message);
            return(item);
        }
        finally
        {
            connection.Close();
        }
        return(item);
    }
コード例 #26
0
    public static List <dbo_LoginHistoryClass> Search(string User_ID)
    {
        SqlConnection connection      = SAMDataClass.GetConnection();
        string        selectProcedure = "[LoginHistorySearch]";
        SqlCommand    selectCommand   = new SqlCommand(selectProcedure, connection);

        selectCommand.CommandType = CommandType.StoredProcedure;


        if (User_ID != null)
        {
            selectCommand.Parameters.AddWithValue("@User_ID", User_ID);
        }
        else
        {
            selectCommand.Parameters.AddWithValue("@User_ID", DBNull.Value);
        }


        DataTable dt = new DataTable();
        List <dbo_LoginHistoryClass> item = new List <dbo_LoginHistoryClass>();


        try
        {
            connection.Open();
            SqlDataReader reader1 = selectCommand.ExecuteReader();
            if (reader1.HasRows)
            {
                dt.Load(reader1);

                foreach (DataRow reader in dt.Rows)
                {
                    item.Add(new dbo_LoginHistoryClass()
                    {
                        User_ID    = reader["User_ID"] is DBNull ? null : reader["User_ID"].ToString(),
                        Login_Time = reader["Login_Time"] is DBNull ? null : (DateTime?)reader["Login_Time"],
                        Status     = reader["Status"] is DBNull ? null : reader["Status"].ToString()
                    });
                }
            }
            reader1.Close();
        }
        catch (SqlException ex)
        {
            logger.Error(ex.Message);
            return(item);
        }
        finally
        {
            connection.Close();
        }
        return(item);
    }
コード例 #27
0
    public static List <dbo_RequisitionClass> SelectByRequisitionNo(String Requisition_No)
    {
        logger.Info(HttpContext.Current.Request.Cookies["User_ID"].Value + " " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString() + " " + System.Reflection.MethodBase.GetCurrentMethod().Name);

        List <dbo_RequisitionClass> clsdbo_Requisition = new List <dbo_RequisitionClass>();
        SqlConnection connection      = SAMDataClass.GetConnection();
        string        selectProcedure = "[RequisitionSelectByRequisitionNo]";
        SqlCommand    selectCommand   = new SqlCommand(selectProcedure, connection);

        selectCommand.CommandType = CommandType.StoredProcedure;
        selectCommand.Parameters.AddWithValue("@Requisition_No", Requisition_No);
        DataTable dt = new DataTable();

        try
        {
            connection.Open();
            SqlDataReader reader1
                = selectCommand.ExecuteReader();
            if (reader1.HasRows)
            {
                dt.Load(reader1);
                foreach (DataRow reader in dt.Rows)
                {
                    clsdbo_Requisition.Add(new dbo_RequisitionClass()
                    {
                        Requisition_No     = reader["Requisition_No"] is DBNull ? null : reader["Requisition_No"].ToString(),
                        Time_No            = reader["Time_No"] is DBNull ? null : reader["Time_No"].ToString(),
                        User_ID            = reader["User_ID"] is DBNull ? null : reader["User_ID"].ToString(),
                        Requisition_Date   = reader["Requisition_Date"] is DBNull ? null : (DateTime?)reader["Requisition_Date"],
                        Transaction_Date   = reader["Transaction_Date"] is DBNull ? null : (DateTime?)reader["Transaction_Date"],
                        Grand_Total_Qty    = reader["Grand_Total_Qty"] is DBNull ? null : (Int32?)reader["Grand_Total_Qty"],
                        Grand_Total_Amount = reader["Grand_Total_Amount"] is DBNull ? null : (Decimal?)reader["Grand_Total_Amount"],
                        Total_Commission   = reader["Total_Commission"] is DBNull ? null : (Decimal?)reader["Total_Commission"],
                        Tota_Point         = reader["Tota_Point"] is DBNull ? null : (Int16?)reader["Tota_Point"],
                        Status             = reader["Status"] is DBNull ? null : reader["Status"].ToString(),
                        Replace_Sales      = reader["Replace_Sales"] is DBNull ? null : reader["Replace_Sales"].ToString()
                    });
                }
            }

            reader1.Close();
        }
        catch (SqlException ex)
        {
            logger.Error(ex.Message);
            return(clsdbo_Requisition);
        }
        finally
        {
            connection.Close();
        }
        return(clsdbo_Requisition);
    }
コード例 #28
0
    public static bool DeletebyTimeNo(String Requisition_No, String Time_No)
    {
        logger.Info(System.Web.HttpContext.Current.Request.Cookies["User_ID"].Value == null ? string.Empty : System.Web.HttpContext.Current.Request.Cookies["User_ID"].Value + " " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString() + " " + System.Reflection.MethodBase.GetCurrentMethod().Name);
        SqlConnection connection      = SAMDataClass.GetConnection();
        string        deleteProcedure = "[dbo].[RequisitionDetailDeletebyTimeNo]";
        SqlCommand    deleteCommand   = new SqlCommand(deleteProcedure, connection);

        deleteCommand.CommandType = CommandType.StoredProcedure;

        if (Requisition_No != null)
        {
            deleteCommand.Parameters.AddWithValue("@OldRequisition_No", Requisition_No);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldRequisition_No", DBNull.Value);
        }
        if (Time_No != null)
        {
            deleteCommand.Parameters.AddWithValue("@OldTime_No", Time_No);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldTime_No", DBNull.Value);
        }

        deleteCommand.Parameters.Add("@ReturnValue", System.Data.SqlDbType.Int);
        deleteCommand.Parameters["@ReturnValue"].Direction = ParameterDirection.Output;
        try
        {
            connection.Open();
            deleteCommand.ExecuteNonQuery();
            int count = System.Convert.ToInt32(deleteCommand.Parameters["@ReturnValue"].Value);
            if (count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        catch (SqlException ex)
        {
            logger.Error(ex.Message);
            return(false);
        }
        finally
        {
            connection.Close();
        }
    }
コード例 #29
0
    public static dbo_SalesTargetClass Select_Record(String Sales_Target_ID)
    {
        dbo_SalesTargetClass clsdbo_SalesTarget = new dbo_SalesTargetClass();
        SqlConnection        connection         = SAMDataClass.GetConnection();
        string     selectProcedure = "[SalesTargetSelectByID]";
        SqlCommand selectCommand   = new SqlCommand(selectProcedure, connection);

        selectCommand.CommandType = CommandType.StoredProcedure;


        if (!string.IsNullOrEmpty(Sales_Target_ID))
        {
            selectCommand.Parameters.AddWithValue("@Sales_Target_ID", Sales_Target_ID);
        }
        else
        {
            selectCommand.Parameters.AddWithValue("@Sales_Target_ID", DBNull.Value);
        }



        try
        {
            connection.Open();
            SqlDataReader reader
                = selectCommand.ExecuteReader(CommandBehavior.SingleRow);
            if (reader.Read())
            {
                clsdbo_SalesTarget.Sales_Target_ID = reader["Sales_Target_ID"] is DBNull ? null : reader["Sales_Target_ID"].ToString();
                clsdbo_SalesTarget.CV_Code         = reader["CV_Code"] is DBNull ? null : reader["CV_Code"].ToString();
                clsdbo_SalesTarget.Year            = reader["Year"] is DBNull ? null : reader["Year"].ToString();
                clsdbo_SalesTarget.Month           = reader["Month"] is DBNull ? null : reader["Month"].ToString();
                clsdbo_SalesTarget.Sales_Target    = reader["Sales_Target"] is DBNull ? null : (Decimal?)reader["Sales_Target"];
                clsdbo_SalesTarget.Actual_Sales    = reader["Actual_Sales"] is DBNull ? null : (Decimal?)reader["Actual_Sales"];
            }
            else
            {
                clsdbo_SalesTarget = null;
            }
            reader.Close();
        }
        catch (SqlException ex)
        {
            logger.Error(ex.Message);
            return(clsdbo_SalesTarget);
        }
        finally
        {
            connection.Close();
        }
        return(clsdbo_SalesTarget);
    }
コード例 #30
0
    public static bool Update(dbo_CycleAssignmentClass newdbo_CycleAssignmentClass)
    {
        SqlConnection connection      = SAMDataClass.GetConnection();
        string        updateProcedure = "CycleAssignmentUpdate";
        SqlCommand    updateCommand   = new SqlCommand(updateProcedure, connection);

        updateCommand.CommandType = CommandType.StoredProcedure;
        if (newdbo_CycleAssignmentClass.Order_Cycle_ID != null)
        {
            updateCommand.Parameters.AddWithValue("@NewOrder_Cycle_ID", newdbo_CycleAssignmentClass.Order_Cycle_ID);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@NewOrder_Cycle_ID", DBNull.Value);
        }
        if (newdbo_CycleAssignmentClass.CV_Code != null)
        {
            updateCommand.Parameters.AddWithValue("@NewCV_Code", newdbo_CycleAssignmentClass.CV_Code);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@NewCV_Code", DBNull.Value);
        }



        updateCommand.Parameters.Add("@ReturnValue", System.Data.SqlDbType.Int);
        updateCommand.Parameters["@ReturnValue"].Direction = ParameterDirection.Output;
        try
        {
            connection.Open();
            updateCommand.ExecuteNonQuery();
            int count = System.Convert.ToInt32(updateCommand.Parameters["@ReturnValue"].Value);
            if (count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        catch (SqlException ex)
        {
            logger.Error(ex.Message);
            return(false);
        }
        finally
        {
            connection.Close();
        }
    }