Exemplo n.º 1
0
    public static string InsertRegion(string SupplierTitle, string SupplierCode, string Phone, string Fax, string Email, string AddressLine1, string AddressLine2, string NTN, string GST, string SRB, string opBal, string UserID)
    {
        string        retMessage = string.Empty;
        string        msg        = "";
        SqlConnection Conn       = new SqlConnection(ConfigurationManager.ConnectionStrings["Con"].ConnectionString);
        SqlConnection ConACC     = new SqlConnection(ConfigurationManager.ConnectionStrings["ConACC"].ConnectionString);

        string       ID              = AACommon.GetAlphaNumericIDSIX("Supplier", "SIP-", "SupplierID", Conn);
        SqlParameter SupplierID_P    = new SqlParameter("@SupplierID", ID);
        SqlParameter SupplierTitle_P = new SqlParameter("@SupplierTitle", SupplierTitle);
        SqlParameter SupplierCode_P  = new SqlParameter("@SupplierCode", SupplierCode);
        SqlParameter Phone_P         = new SqlParameter("@Phone", Phone);
        SqlParameter Fax_P           = new SqlParameter("@Fax", Fax);
        SqlParameter Email_P         = new SqlParameter("@Email", Email);
        SqlParameter AddressLine1_P  = new SqlParameter("@AddressLine1", AddressLine1);
        SqlParameter AddressLine2_P  = new SqlParameter("@AddressLine2", AddressLine2);
        SqlParameter NTN_P           = new SqlParameter("@NTN", NTN);
        SqlParameter GST_P           = new SqlParameter("@GST", GST);
        SqlParameter SRB_P           = new SqlParameter("@SRB", SRB);
        SqlParameter OpBal           = new SqlParameter("@OpBal", opBal);
        SqlParameter CREATEBY        = new SqlParameter("@CreateBy", UserID);

        msg = AACommon.Execute("Supplier_Insert", Conn, SupplierID_P, SupplierTitle_P, SupplierCode_P, Phone_P, Fax_P, Email_P, AddressLine1_P, AddressLine2_P, NTN_P, GST_P, SRB_P, OpBal, CREATEBY);



        /////////////////////ACCOUNTS /////////////////////////
        string opD = "0"; string opC = "0";

        if (Convert.ToDecimal(opBal) > 0)
        {
            opD = opBal; opC = "0";
        }
        else if (Convert.ToDecimal(opBal) < 0)
        {
            opD = "0"; opC = opBal;
        }

        string       L4ID              = AACommon.GetData("SELECT AccountID FROM AACCOUNTS_Integration WHERE (Description = 'Vendors')", ConACC, "AccountID");
        string       ledgerID          = AACommon.GetAlphaNumericIDTHREE("Accounts", L4ID, "L4_ID", ConACC);
        SqlParameter L4_ID             = new SqlParameter("@L4_ID", ledgerID);
        SqlParameter Desc_Level4       = new SqlParameter("@Desc_Level4", SupplierTitle);
        SqlParameter L4_IDNew          = new SqlParameter("@L4_IDNew", L4ID);
        SqlParameter Opdr              = new SqlParameter("@Opdr", opD);
        SqlParameter Opcr              = new SqlParameter("@Opcr", opC);
        SqlParameter CompanyID         = new SqlParameter("@CompanyID", "12");
        SqlParameter FiscalID          = new SqlParameter("@FiscalID", "22");
        SqlParameter BalanceValidation = new SqlParameter("@BalanceValidation", "0");

        AACommon.Execute("Insert_Accounts", ConACC, L4_ID, Desc_Level4, L4_IDNew, Opdr, Opcr, CompanyID, FiscalID, BalanceValidation);
        /////////////////////////////////////

        string     str = "update Supplier set LedgerID='" + ledgerID + "' where SupplierID='" + ID + "'";
        SqlCommand cmd = new SqlCommand(str, Conn);

        if (Conn.State == ConnectionState.Closed)
        {
            Conn.Open();
        }
        cmd.ExecuteNonQuery();
        if (Conn.State == ConnectionState.Open)
        {
            Conn.Close();
        }



        if (msg == "Record Saved Successfully")
        {
            retMessage = "true";
        }
        else
        {
            retMessage = "false";
        }

        return(retMessage);
    }
Exemplo n.º 2
0
    public static string InsertRegion(string CustomerTitle, string CustomerCode, string Phone, string Fax, string Email, string AddressLine1, string AddressLine2, string NTN, string GST, string SRB, string UserID, string InvDays, string AgDays, string opBal, string txtCellNo, string txtPhone2, string txtCNIC, string ddlBookingDay, string ddlDeliveryDay, string ddlCustomerTypeID)
    {
        string        retMessage = string.Empty;
        string        msg        = "";
        SqlConnection Conn       = new SqlConnection(ConfigurationManager.ConnectionStrings["Con"].ConnectionString);
        SqlConnection ConACC     = new SqlConnection(ConfigurationManager.ConnectionStrings["ConACC"].ConnectionString);

        string       ID              = AACommon.GetAlphaNumericIDSIX("Customer", "CUS-", "CustomerID", Conn);
        SqlParameter CustomerID_P    = new SqlParameter("@CustomerID", ID);
        SqlParameter CustomerTitle_P = new SqlParameter("@CustomerTitle", CustomerTitle);
        SqlParameter CustomerCode_P  = new SqlParameter("@CustomerCode", CustomerCode);
        SqlParameter Phone_P         = new SqlParameter("@Phone", Phone);
        SqlParameter Fax_P           = new SqlParameter("@Fax", Fax);
        SqlParameter Email_P         = new SqlParameter("@Email", Email);
        SqlParameter AddressLine1_P  = new SqlParameter("@AddressLine1", AddressLine1);
        SqlParameter AddressLine2_P  = new SqlParameter("@AddressLine2", AddressLine2);
        SqlParameter NTN_P           = new SqlParameter("@NTN", NTN);
        SqlParameter GST_P           = new SqlParameter("@GST", GST);
        SqlParameter SRB_P           = new SqlParameter("@SRB", SRB);

        SqlParameter InvoiceDays = new SqlParameter("@InvoiceDays", InvDays);
        SqlParameter AgingDays   = new SqlParameter("@AgingDays", AgDays);
        SqlParameter OpBal       = new SqlParameter("@OpBal", opBal);

        SqlParameter CREATEBY = new SqlParameter("@CreateBy", UserID);


        SqlParameter CellNo         = new SqlParameter("@CellNo", txtCellNo);
        SqlParameter Phone2         = new SqlParameter("@Phone2", txtPhone2);
        SqlParameter CNIC           = new SqlParameter("@CNIC", txtCNIC);
        SqlParameter BookingDay     = new SqlParameter("@BookingDay", ddlBookingDay);
        SqlParameter DeliveryDay    = new SqlParameter("@DeliveryDay", ddlDeliveryDay);
        SqlParameter CustomerTypeID = new SqlParameter("@CustomerTypeID", ddlCustomerTypeID);

        msg = AACommon.Execute("Customer_InsertV2", Conn, CustomerID_P, CustomerTitle_P, CustomerCode_P, Phone_P, Fax_P, Email_P, AddressLine1_P, AddressLine2_P, NTN_P, GST_P, SRB_P, InvoiceDays, AgingDays, OpBal, CREATEBY, CellNo, Phone2, CNIC, BookingDay, DeliveryDay, CustomerTypeID);


        //Changes by SA //

        /////////////////////ACCOUNTS /////////////////////////
        string opD = "0"; string opC = "0";

        if (Convert.ToDecimal(opBal) > 0)
        {
            opD = opBal; opC = "0";
        }
        else if (Convert.ToDecimal(opBal) < 0)
        {
            opD = "0"; opC = opBal;
        }

        string       L4ID              = AACommon.GetData("SELECT AccountID FROM AACCOUNTS_Integration WHERE (Description = 'Accounts Receivable')", ConACC, "AccountID");
        string       ledgerID          = AACommon.GetAlphaNumericIDTHREE("Accounts", L4ID, "L4_ID", ConACC);
        SqlParameter L4_ID             = new SqlParameter("@L4_ID", ledgerID);
        SqlParameter Desc_Level4       = new SqlParameter("@Desc_Level4", CustomerTitle);
        SqlParameter L4_IDNew          = new SqlParameter("@L4_IDNew", L4ID);
        SqlParameter Opdr              = new SqlParameter("@Opdr", opD);
        SqlParameter Opcr              = new SqlParameter("@Opcr", opC);
        SqlParameter CompanyID         = new SqlParameter("@CompanyID", "12");
        SqlParameter FiscalID          = new SqlParameter("@FiscalID", "22");
        SqlParameter BalanceValidation = new SqlParameter("@BalanceValidation", "0");

        AACommon.Execute("Insert_Accounts", ConACC, L4_ID, Desc_Level4, L4_IDNew, Opdr, Opcr, CompanyID, FiscalID, BalanceValidation);
        /////////////////////////////////////

        string     str = "update Customer set LedgerID='" + ledgerID + "' where CustomerID='" + ID + "'";
        SqlCommand cmd = new SqlCommand(str, Conn);

        if (Conn.State == ConnectionState.Closed)
        {
            Conn.Open();
        }
        cmd.ExecuteNonQuery();
        if (Conn.State == ConnectionState.Open)
        {
            Conn.Close();
        }

        //Changes by SA //

        if (msg == "Record Saved Successfully")
        {
            retMessage = "true";
        }
        else
        {
            retMessage = "false";
        }

        return(retMessage);
    }