private static string UpdateProformaInvoice(Proforma_Invoice _Proforma_Invoice)
        {
            DbCommand command = Catalog_Access.CreateCommand();
            //Have to wite the stored procedure
            command.CommandText = "sp_update_Proforma_Invoice";

            DbParameter param;

            #region
            param = command.CreateParameter();
            param.ParameterName = "@ID";
            param.Value = _Proforma_Invoice.ID;
            param.DbType = DbType.Int32;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@Customer_ID";
            param.Value = _Proforma_Invoice.Customer_ID;
            param.DbType = DbType.Int32;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@Contact_ID";
            param.Value = _Proforma_Invoice.Contact_ID;
            param.DbType = DbType.Int32;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@Customer_Order";
            param.Value = _Proforma_Invoice.Customer_Order;
            param.DbType = DbType.String;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@Date";
            param.Value = _Proforma_Invoice.Date;
            param.DbType = DbType.Date;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@Payment_Info_ID";
            param.Value = _Proforma_Invoice.Payment_Info_ID;
            param.DbType = DbType.String;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@Pi_No";
            param.Value = _Proforma_Invoice.Pi_No;
            param.DbType = DbType.String;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@Supplier_Origin";
            param.Value = _Proforma_Invoice.Supplier_Origin;
            param.DbType = DbType.String;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@Delivery_Method";
            param.Value = _Proforma_Invoice.Delivery_Method;
            param.DbType = DbType.String;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@Customer_Destination";
            param.Value = _Proforma_Invoice.Customer_Destination;
            param.DbType = DbType.String;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@Shipment_Date";
            param.Value = _Proforma_Invoice.Shipment_Date;
            param.DbType = DbType.Date;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@UpdatedBy";
            param.Value = _Proforma_Invoice.UpdatedBy;
            param.DbType = DbType.String;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@Return";
            param.DbType = DbType.String;
            param.Size = 2;
            param.Direction = ParameterDirection.Output;
            command.Parameters.Add(param);
            #endregion

            Catalog_Access.ExecuteNonQuery(command);

            string Return = command.Parameters["@Return"].Value.ToString();

            return Return;
        }
 // update
 public static string Update(Proforma_Invoice _Proforma_Invoice, List<Proforma_Invoice_B> _Proforma_Invoice_B)
 {
     if (UpdateProformaInvoice(_Proforma_Invoice) == "4")
     {
         UpdateCollection(_Proforma_Invoice_B, _Proforma_Invoice.ID, _Proforma_Invoice.UpdatedBy);
         return "4";
     }
     else
     {
         return "1";
     }
 }
        public string Submit(Proforma_Invoice _Proforma_Invoice, List<Proforma_Invoice_B> _Proforma_Invoice_B)
        {
            string msg = "";

            if (_Proforma_Invoice.ID == null)
            {
                _Proforma_Invoice.CreatedBy = Session["User"].ToString();
                msg = Proforma_Invoice_DA.Insert(_Proforma_Invoice, _Proforma_Invoice_B);

            }
            else
            {
                _Proforma_Invoice.UpdatedBy = Session["User"].ToString();
                msg = Proforma_Invoice_DA.Update(_Proforma_Invoice, _Proforma_Invoice_B);
            }

            return msg;
        }
        //insert
        public static string Insert(Proforma_Invoice _Proforma_Invoice, List<Proforma_Invoice_B> _Proforma_Invoice_B)
        {
            int ID = InsertProformaInvoice(_Proforma_Invoice);

            if (ID > 0)
            {
                InsertCollection(_Proforma_Invoice_B, ID, _Proforma_Invoice.CreatedBy);
                return "0";
            }
            else
            {
                return "1";
            }
        }
        public Proforma_Invoice Get_Proforma_Invoice(int ID)
        {
            // Customer Detail
            Proforma_Invoice _Proforma_Invoice = new Proforma_Invoice();

            DataTable dt = Proforma_Invoice_DA.Get_Proforma_Invoice(ID);
            _Proforma_Invoice.Customer_ID = int.Parse(dt.Rows[0]["Customer_ID"].ToString());
            _Proforma_Invoice.Contact_ID = int.Parse(dt.Rows[0]["Contact_ID"].ToString());
            _Proforma_Invoice.Customer_Order = dt.Rows[0]["Customer_Order"].ToString();
            _Proforma_Invoice.stringDate = Convert.ToDateTime(dt.Rows[0]["Date"].ToString()).ToString("MM/dd/yyyy");
            _Proforma_Invoice.Payment_Info_ID = int.Parse(dt.Rows[0]["Payment_Info_ID"].ToString());
            _Proforma_Invoice.Pi_No = dt.Rows[0]["Pi_No"].ToString();
            _Proforma_Invoice.Supplier_Origin = dt.Rows[0]["Supplier_Origin"].ToString();
            _Proforma_Invoice.Delivery_Method = dt.Rows[0]["Delivery_Method"].ToString();
            _Proforma_Invoice.Customer_Destination = dt.Rows[0]["Customer_Destination"].ToString();
            _Proforma_Invoice.Shipment_Date = Convert.ToDateTime(dt.Rows[0]["Shipment_Date"].ToString()).ToString("MM/dd/yyyy");

            return _Proforma_Invoice;
        }