Exemple #1
0
        public LC_Master GetLC_Master(int LC_MasterID, SqlConnection con)
        {
            LC_Master objLCm = new LC_Master();
            DataTable dt     = new DataTable();

            try
            {
                SqlDataAdapter da = new SqlDataAdapter("select * from T_LC_Master where LCID=@LCMasterID", con);

                da.SelectCommand.Parameters.Add("@LCMasterID", SqlDbType.Int).Value = LC_MasterID;

                da.Fill(dt);
                da.Dispose();
                if (dt.Rows.Count == 0)
                {
                    return(null);
                }
                objLCm.LCID = dt.Rows[0].Field <int>("LCID");

                objLCm.LCType     = dt.Rows[0].Field <string>("LCType");
                objLCm.MasterLCID = dt.Rows[0].Field <object>("MasterLCID") == DBNull.Value || dt.Rows[0].Field <object>("MasterLCID") == null ? -1 : dt.Rows[0].Field <int>("MasterLCID");
                objLCm.MasterLCNo = dt.Rows[0].Field <string>("MasterLCNo");
                objLCm.LCNo       = dt.Rows[0].Field <string>("LCNo");
                objLCm.LCDate     = dt.Rows[0].Field <DateTime>("LCDate");
                objLCm.AcceptDate = dt.Rows[0].Field <object>("AcceptDate") == DBNull.Value || dt.Rows[0].Field <object>("AcceptDate") == null ?new DateTime(1900, 1, 1) : dt.Rows[0].Field <DateTime>("AcceptDate");
                objLCm.AtSight    = dt.Rows[0].Field <string>("Asights");
                //objLCm.AtSight = dt.Rows[0].Field<object>("ASights")==DBNull.Value||dt.Rows[0].Field<object>("Asights")==null?0:dt.Rows[0].Field<string>("Asights");
                objLCm.DocumentDate       = dt.Rows[0].Field <object>("DocumentDate") == DBNull.Value || dt.Rows[0].Field <object>("DocumentDate") == null ? new DateTime(1900, 1, 1) : dt.Rows[0].Field <DateTime>("DocumentDate");
                objLCm.ExpiredDate        = dt.Rows[0].Field <object>("ExpireDate") == DBNull.Value || dt.Rows[0].Field <object>("ExpireDate") == null ? new DateTime(1900, 1, 1) : dt.Rows[0].Field <DateTime>("ExpireDate");
                objLCm.FileNo             = dt.Rows[0].Field <string>("FileNo");
                objLCm.IssuBankID         = dt.Rows[0].Field <object>("IssueBank") == DBNull.Value || dt.Rows[0].Field <object>("IssueBank") == null ? -1 : dt.Rows[0].Field <int>("IssueBank");
                objLCm.NegotiationBankID  = dt.Rows[0].Field <object>("NegotiateBank") == DBNull.Value || dt.Rows[0].Field <object>("NegotiateBank") == null ? -1 : dt.Rows[0].Field <int>("NegotiateBank");
                objLCm.NegotiationDate    = dt.Rows[0].Field <object>("NegotiationDate") == DBNull.Value || dt.Rows[0].Field <object>("NegotiationDate") == null ? new DateTime(1900, 1, 1) : dt.Rows[0].Field <DateTime>("NegotiationDate");
                objLCm.ShipmentDate       = dt.Rows[0].Field <object>("ShipmentDate") == DBNull.Value || dt.Rows[0].Field <object>("ShipmentDate") == null ? new DateTime(1900, 1, 1) : dt.Rows[0].Field <DateTime>("ShipmentDate");
                objLCm.UDDate             = dt.Rows[0].Field <object>("UDDate") == DBNull.Value || dt.Rows[0].Field <object>("UDDate") == null ? new DateTime(1900, 1, 1) : dt.Rows[0].Field <DateTime>("UDDate");
                objLCm.TotalQty           = dt.Rows[0].Field <object>("TotalQty") == DBNull.Value || dt.Rows[0].Field <object>("TotalQty") == null ? 0 : Convert.ToDouble(dt.Rows[0].Field <object>("TotalQty"));
                objLCm.TotalValue         = dt.Rows[0].Field <object>("TotalValue") == DBNull.Value || dt.Rows[0].Field <object>("TotalValue") == null?0.0:Convert.ToDouble(dt.Rows[0].Field <object>("TotalValue"));
                objLCm.ActualShipmentDate = dt.Rows[0].Field <object>("ActualShipmentDate") == DBNull.Value || dt.Rows[0].Field <object>("ActualShipmentDate") == null ? new DateTime(1900, 1, 1) : dt.Rows[0].Field <DateTime>("ActualShipmentDate");
                objLCm.UnderLCDate        = dt.Rows[0].Field <object>("UnderLCDate") == DBNull.Value || dt.Rows[0].Field <object>("UnderLCDate") == null ? new DateTime(1900, 1, 1) : dt.Rows[0].Field <DateTime>("UnderLCDate");
                objLCm.PaymentDate        = dt.Rows[0].Field <object>("PayDate") == DBNull.Value || dt.Rows[0].Field <object>("PayDate") == null ? new DateTime(1900, 1, 1) : dt.Rows[0].Field <DateTime>("PayDate");
                objLCm.ActualPaymentDate  = dt.Rows[0].Field <object>("PayDate") == DBNull.Value || dt.Rows[0].Field <object>("ActualPayDate") == null ? new DateTime(1900, 1, 1) : dt.Rows[0].Field <DateTime>("ActualPayDate");
                objLCm.CustomerSupplierID = dt.Rows[0].Field <object>("CustSuppID") == DBNull.Value || dt.Rows[0].Field <object>("CustSuppID") == null ? 0 : dt.Rows[0].Field <int>("CustSuppID");
                objLCm.CurrencyID         = dt.Rows[0].Field <object>("CurrencyID") == DBNull.Value || dt.Rows[0].Field <object>("CurrencyID") == null ? 0 : dt.Rows[0].Field <int>("CurrencyID");
                objLCm.Rate          = Convert.ToDouble(dt.Rows[0].Field <object>("Rate"));
                objLCm.LcUnit        = GlobalFunctions.isNull(dt.Rows[0].Field <object>("lcUnit"), "");
                objLCm.LCDescription = GlobalFunctions.isNull(dt.Rows[0].Field <object>("Remarks"), "");

                return(objLCm);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #2
0
        public int SaveUpdateLCMaster(LC_Master objLCMaster, SqlConnection con, SqlTransaction trans)
        {
            SqlCommand com = null;

            int ID = 0;

            try
            {
                com = new SqlCommand();

                com.Connection  = con;
                com.Transaction = trans;
                com.CommandText = "spInsertUpdateLCMaster";
                com.CommandType = CommandType.StoredProcedure;
                com.Parameters.Add("@LCID", SqlDbType.Int).Value                = objLCMaster.LCID;
                com.Parameters.Add("@LCNo", SqlDbType.VarChar, 100).Value       = objLCMaster.LCNo;
                com.Parameters.Add("@LCType", SqlDbType.VarChar, 100).Value     = objLCMaster.LCType;
                com.Parameters.Add("@MasterLCNo", SqlDbType.VarChar, 100).Value = objLCMaster.MasterLCNo;
                if (objLCMaster.MasterLCID <= 0)
                {
                    com.Parameters.Add("@MasterLCID", SqlDbType.Int).Value = DBNull.Value;
                }
                else
                {
                    com.Parameters.Add("@MasterLCID", SqlDbType.Int).Value = objLCMaster.MasterLCID;
                }
                com.Parameters.Add("@LCDate", SqlDbType.DateTime).Value          = objLCMaster.LCDate;
                com.Parameters.Add("@ShipmentDate", SqlDbType.DateTime).Value    = objLCMaster.ShipmentDate;
                com.Parameters.Add("@ExpireDate", SqlDbType.DateTime).Value      = objLCMaster.ExpiredDate;
                com.Parameters.Add("@DocumentDate", SqlDbType.DateTime).Value    = objLCMaster.DocumentDate == new DateTime(1900, 1, 1) ? DBNull.Value : (object)objLCMaster.DocumentDate;
                com.Parameters.Add("@NegotiationDate", SqlDbType.DateTime).Value = objLCMaster.NegotiationDate == new DateTime(1900, 1, 1) ? DBNull.Value : (object)objLCMaster.NegotiationDate;
                com.Parameters.Add("@UDDate", SqlDbType.DateTime).Value          = objLCMaster.UDDate == new DateTime(1900, 1, 1) ? DBNull.Value : (object)objLCMaster.UDDate;

                com.Parameters.Add("@AcceptDate", SqlDbType.DateTime).Value = objLCMaster.AcceptDate == new DateTime(1900, 1, 1) ? DBNull.Value : (object)objLCMaster.AcceptDate;
                com.Parameters.Add("@FileNo", SqlDbType.VarChar, 100).Value = objLCMaster.FileNo;
                if (objLCMaster.IssuBankID <= 0)
                {
                    com.Parameters.Add("@IssuBankID", SqlDbType.Int).Value = DBNull.Value;
                }
                else
                {
                    com.Parameters.Add("@IssuBankID", SqlDbType.Int).Value = objLCMaster.IssuBankID;
                }
                if (objLCMaster.NegotiationBankID <= 0)
                {
                    com.Parameters.Add("@NegotiationBankID", SqlDbType.Int).Value = DBNull.Value;
                }
                else
                {
                    com.Parameters.Add("@NegotiationBankID", SqlDbType.Int).Value = objLCMaster.NegotiationBankID;
                }
                com.Parameters.Add("@AtSight", SqlDbType.VarChar, 50).Value = objLCMaster.AtSight;
                com.Parameters.Add("@TotalQty", SqlDbType.Money).Value      = objLCMaster.TotalQty;
                com.Parameters.Add("@TotalValue", SqlDbType.Money).Value    = objLCMaster.TotalValue;
                if (objLCMaster.CurrencyID <= 0)
                {
                    com.Parameters.Add("@CurrencyID", SqlDbType.Int).Value = DBNull.Value;
                }
                else
                {
                    com.Parameters.Add("@CurrencyID", SqlDbType.Int).Value = objLCMaster.CurrencyID;
                }
                com.Parameters.Add("@CompanyID", SqlDbType.Int).Value = LogInInfo.CompanyID;
                com.Parameters.Add("@UserID", SqlDbType.Int).Value    = LogInInfo.UserID;
                if (objLCMaster.UnderLCDate == new DateTime(1900, 1, 1))
                {
                    com.Parameters.Add("@UnderLCDate", SqlDbType.DateTime).Value = DBNull.Value;
                }
                else
                {
                    com.Parameters.Add("@UnderLCDate", SqlDbType.DateTime).Value = objLCMaster.UnderLCDate;
                }
                if (objLCMaster.ActualShipmentDate == new DateTime(1900, 1, 1))
                {
                    com.Parameters.Add("@ActualShipmentDate", SqlDbType.DateTime).Value = DBNull.Value;
                }
                else
                {
                    com.Parameters.Add("@ActualShipmentDate", SqlDbType.DateTime).Value = objLCMaster.ActualShipmentDate;
                }
                com.Parameters.Add("@PayDate", SqlDbType.DateTime).Value       = objLCMaster.PaymentDate == new DateTime(1900, 1, 1) ? DBNull.Value : (object)objLCMaster.PaymentDate;
                com.Parameters.Add("@ActualPayDate", SqlDbType.DateTime).Value = objLCMaster.ActualPaymentDate == new DateTime(1900, 1, 1) ? DBNull.Value : (object)objLCMaster.ActualPaymentDate;
                com.Parameters.Add("@CustSuppID", SqlDbType.Int).Value         = objLCMaster.CustomerSupplierID;
                com.Parameters.Add("@Rate", SqlDbType.Money).Value             = objLCMaster.Rate;
                com.Parameters.Add("@LcUnit", SqlDbType.VarChar, 100).Value    = objLCMaster.LcUnit;
                com.Parameters.Add("@Remarks", SqlDbType.VarChar, 500).Value   = objLCMaster.LCDescription;
                com.ExecuteNonQuery();


                if (objLCMaster.LCID == 0)
                {
                    ID = ConnectionHelper.GetIDForInsert(con, trans, "LCID", " T_LC_Master");
                }
                else
                {
                    ID = objLCMaster.LCID;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(ID);
        }