예제 #1
0
        private static Guid GetAccountTypeCID(Guid?AccountID)
        {
            SqlConnection  con = SyncHelper.NewCRMConnection();
            SqlCommand     com = new SqlCommand();
            SqlDataAdapter ad  = new SqlDataAdapter(com);

            System.Text.StringBuilder sql = new System.Text.StringBuilder();
            sql.AppendLine("SELECT AccountTypeCID FROM Account WHERE AccountID = @AccountID");

            com.CommandText    = sql.ToString();
            com.CommandType    = CommandType.Text;
            com.Connection     = con;
            com.CommandTimeout = int.MaxValue;

            try
            {
                con.Open();
                com.Parameters.Add(new SqlParameter("@AccountID", AccountID));

                DataTable dt = new DataTable();
                ad.Fill(dt);
                return(new Guid(dt.Rows[0][0].ToString()));
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                con.Close();
            }
        }
예제 #2
0
        internal static bool IsNonMSC(Guid?AccountID)
        {
            Nullable <Guid> NonMSCAccountTypeCID = SyncHelper.GetCodeMasterID("Non MSC", BOL.AppConst.CodeType.AccountType);

            if (NonMSCAccountTypeCID.HasValue)
            {
                Guid accountTypeCID = GetAccountTypeCID(AccountID);
                return(accountTypeCID == NonMSCAccountTypeCID.Value);
            }
            else
            {
                return(false);
            }
        }
예제 #3
0
        private static Guid CreateCodeMaster(string Value, string CodeType)
        {
            Guid codeMasterID = Guid.NewGuid();

            SqlConnection con = SyncHelper.NewCRMConnection();
            SqlCommand    com = new SqlCommand();

            System.Text.StringBuilder sql = new System.Text.StringBuilder();
            sql.AppendLine("INSERT INTO CodeMaster (CodeMasterID, SeqNo, CodeType, CodeName,");
            sql.AppendLine("CreatedBy,CreatedByName,ModifiedBy,ModifiedByName,CreatedDate,ModifiedDate) ");
            sql.AppendLine("VALUES (@CodeMasterID, 0, @CodeType, @CodeName, ");
            sql.AppendLine("@CreatedBy, @CreatedByName, @ModifiedBy, @ModifiedByName,@CreatedDate,@ModifiedDate ) ");

            com.CommandText = sql.ToString();
            com.CommandType = CommandType.Text;
            com.Connection  = con;
            codeMasterID    = Guid.NewGuid();
            com.Parameters.Add(new SqlParameter("@CodeMasterID", codeMasterID));
            com.Parameters.Add(new SqlParameter("@CodeType", CodeType));
            com.Parameters.Add(new SqlParameter("@CodeName", Value));
            com.Parameters.Add(new SqlParameter("@CreatedBy", SyncHelper.AdminID));
            com.Parameters.Add(new SqlParameter("@CreatedByName", SyncHelper.AdminName));
            com.Parameters.Add(new SqlParameter("@ModifiedBy", SyncHelper.AdminID));
            com.Parameters.Add(new SqlParameter("@ModifiedByName", SyncHelper.AdminName));
            com.Parameters.Add(new SqlParameter("@CreatedDate", DateTime.Now));
            com.Parameters.Add(new SqlParameter("@ModifiedDate", DateTime.Now));

            try
            {
                con.Open();
                com.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                con.Close();
            }

            return(codeMasterID);
        }
예제 #4
0
        internal static Guid?GetAccountIDByFileID(string FileID)
        {
            SqlConnection  con = SyncHelper.NewCRMConnection();
            SqlCommand     com = new SqlCommand();
            SqlDataAdapter ad  = new SqlDataAdapter(com);

            System.Text.StringBuilder sql = new System.Text.StringBuilder();
            sql.AppendLine("SELECT AccountID FROM Account WHERE MSCFileID = @FileID");

            com.CommandText    = sql.ToString();
            com.CommandType    = CommandType.Text;
            com.Connection     = con;
            com.CommandTimeout = int.MaxValue;

            //con.Open()
            try
            {
                com.Parameters.Add(new SqlParameter("@FileID", FileID));

                DataTable dt = new DataTable();
                ad.Fill(dt);

                if (dt.Rows.Count > 0)
                {
                    return(new Guid(dt.Rows[0][0].ToString()));
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                con.Close();
            }
        }