Esempio n. 1
0
        public static int AddressInfoAdd(string SPID, string CustID, AddressInfo Address, out long NewAddressID, out string ErrMsg)
        {
            int Result = ErrorDefinition.IError_Result_UnknowError_Code;
            ErrMsg = ErrorDefinition.BT_IError_Result_UnknowError_Msg;
            SqlConnection myCon = new SqlConnection(DBUtility.BestToneCenterConStr);
            SqlTransaction myTrans = null;
            try
            {
                myCon.Open();
                myTrans = myCon.BeginTransaction();
                SqlCommand cmd = new SqlCommand();
                cmd.Connection = myTrans.Connection;
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "AddressInfoAdd";
                cmd.Transaction = myTrans;

                SqlParameter parSPID = new SqlParameter("@SPID", SqlDbType.VarChar, 8);
                parSPID.Value = SPID;
                cmd.Parameters.Add(parSPID);

                SqlParameter parCustID = new SqlParameter("@CustID", SqlDbType.VarChar, 16);
                parCustID.Value = CustID;
                cmd.Parameters.Add(parCustID);

                SqlParameter parNewAddressID = new SqlParameter("@NewAddressID", SqlDbType.BigInt, 8);
                parNewAddressID.Direction = ParameterDirection.Output;
                cmd.Parameters.Add(parNewAddressID);

                SqlParameter parAreaCode = new SqlParameter("@AreaCode", SqlDbType.VarChar, 6);
                parAreaCode.Value = Address.AreaCode == null ? "" : Address.AreaCode;
                cmd.Parameters.Add(parAreaCode);

                SqlParameter parAddress = new SqlParameter("@Address", SqlDbType.VarChar, 256);
                parAddress.Value = Address.Address == null ? "" : Address.Address;
                cmd.Parameters.Add(parAddress);

                SqlParameter parZipcode = new SqlParameter("@Zipcode", SqlDbType.VarChar, 6);
                parZipcode.Value = Address.Zipcode == null ? "" : Address.Zipcode;
                cmd.Parameters.Add(parZipcode);

                SqlParameter parType = new SqlParameter("@Type", SqlDbType.VarChar, 20);
                parType.Value = Address.Type == null ? "" : Address.Type;
                cmd.Parameters.Add(parType);

                SqlParameter parOtherType = new SqlParameter("@OtherType", SqlDbType.VarChar, 50);
                parOtherType.Value = Address.OtherType == null ? "" : Address.OtherType;
                cmd.Parameters.Add(parOtherType);

                SqlParameter parRelationPerson = new SqlParameter("@RelationPerson", SqlDbType.VarChar, 20);
                parRelationPerson.Value = Address.RelationPerson == null ? "" : Address.RelationPerson;
                cmd.Parameters.Add(parRelationPerson);

                SqlParameter parMobile = new SqlParameter("@Mobile", SqlDbType.VarChar, 20);
                parMobile.Value = Address.Mobile == null ? "" : Address.Mobile;
                cmd.Parameters.Add(parMobile);

                SqlParameter parFixedPhone = new SqlParameter("@FixedPhone", SqlDbType.VarChar, 20);
                parFixedPhone.Value = Address.FixedPhone == null ? "" : Address.FixedPhone;
                cmd.Parameters.Add(parFixedPhone);

                SqlParameter parResult = new SqlParameter("@Result", SqlDbType.Int, 4);
                parResult.Direction = ParameterDirection.Output;
                cmd.Parameters.Add(parResult);

                SqlParameter parErrMsg = new SqlParameter("@ErrMsg", SqlDbType.VarChar, 256);
                parErrMsg.Direction = ParameterDirection.Output;
                cmd.Parameters.Add(parErrMsg);

                cmd.ExecuteNonQuery();

                NewAddressID = int.Parse(parNewAddressID.Value.ToString().Trim());
                Result = int.Parse(parResult.Value.ToString().Trim());
                ErrMsg = parErrMsg.Value.ToString().Trim();

                if (Result != 0)
                {
                    myTrans.Rollback();
                    return Result;
                }
                myTrans.Commit();
            }
            catch (Exception e)
            {
                if (myTrans != null)
                {
                    myTrans.Rollback();
                }
                NewAddressID = -1;
                Result = ErrorDefinition.BT_IError_Result_System_UnknowError_Code;
                ErrMsg = ErrorDefinition.BT_IError_Result_System_UnknowError_Msg + e.Message;
            }
            finally
            {
                if (myCon.State != ConnectionState.Closed)
                {
                    myCon.Close();
                }
            }
            return Result;
        }
Esempio n. 2
0
        public static AddressInfo AddressInfoLoad(string SPID, long AddressID, out int Result, out string ErrMsg)
        {
            AddressInfo Address = null;
            Result = ErrorDefinition.IError_Result_UnknowError_Code;
            ErrMsg = ErrorDefinition.BT_IError_Result_UnknowError_Msg;
            SqlConnection myCon = new SqlConnection(DBUtility.BestToneCenterConStr);
            try
            {
                SqlCommand cmd = new SqlCommand();
                DataSet ds = null;
                cmd.Connection = myCon;
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "AddressInfoLoad";

                SqlParameter parSPID = new SqlParameter("@SPID", SqlDbType.VarChar, 8);
                parSPID.Value = SPID;
                cmd.Parameters.Add(parSPID);

                SqlParameter parAddressID = new SqlParameter("@AddressID", SqlDbType.BigInt, 8);
                parAddressID.Value = AddressID;
                cmd.Parameters.Add(parAddressID);

                SqlParameter parResult = new SqlParameter("@Result", SqlDbType.Int, 4);
                parResult.Direction = ParameterDirection.Output;
                cmd.Parameters.Add(parResult);

                SqlParameter parErrMsg = new SqlParameter("@ErrMsg", SqlDbType.VarChar, 256);
                parErrMsg.Direction = ParameterDirection.Output;
                cmd.Parameters.Add(parErrMsg);

                ds = DBUtility.FillData(cmd, DBUtility.BestToneCenterConStr);
                Result = int.Parse(parResult.Value.ToString().Trim());
                ErrMsg = parErrMsg.Value.ToString().Trim();
                if ( Result == 0 && ds != null )
                {
                    if (ds.Tables.Count != 0)
                    {
                        if (ds.Tables[0].Rows.Count != 0)
                        {

                          Address = new AddressInfo();
                          Address.AddressID = long.Parse(ds.Tables[0].Rows[0]["SequenceID"].ToString().Trim());
                          Address.AreaCode = ds.Tables[0].Rows[0]["AreaCode"].ToString().Trim();
                          Address.Address = ds.Tables[0].Rows[0]["Address"].ToString().Trim();
                          Address.Zipcode = ds.Tables[0].Rows[0]["ZipCode"].ToString().Trim();
                          Address.Type = ds.Tables[0].Rows[0]["Type"].ToString().Trim();
                          Address.OtherType = ds.Tables[0].Rows[0]["OtherType"].ToString().Trim();
                          Address.RelationPerson = ds.Tables[0].Rows[0]["RelationPerson"].ToString().Trim();
                          Address.Mobile = ds.Tables[0].Rows[0]["Mobile"].ToString().Trim();
                          Address.FixedPhone = ds.Tables[0].Rows[0]["FixedPhone"].ToString().Trim();
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Result = ErrorDefinition.IError_Result_System_UnknowError_Code;
                ErrMsg = "��ȡ�ͻ����õ�ַ��Ϣ�����" + e.Message;
            }
            return Address;
        }