Beispiel #1
0
        public static HORep_ManageResultString SaveHOReplenishment(NameValueCollection querystring, NameValueCollection formdata)
        {
            int     intParser;
            decimal decimalParser;

            var HORep = new HORep_CVForReplenishment();

            HORep.ID = Int32.TryParse(querystring.Get("intIDDisHOReplenishment"), out intParser) ? intParser : 0;
            HORep.TransactionDate = querystring.Get("TransactionDate");
            HORep.intIDMasPayee   = Int32.TryParse(querystring.Get("intIDMasPayee"), out intParser) ? intParser : 0;
            HORep.intIDMasCOAIndividualSubsidiaryRF  = Int32.TryParse(querystring.Get("intIDMasCOAIndividualSubsidiaryRF"), out intParser) ? intParser : 0;
            HORep.intIDMasCOAIndividualSubsidiaryCiB = Int32.TryParse(querystring.Get("intIDMasCOAIndividualSubsidiaryCiB"), out intParser) ? intParser : 0;
            HORep.strCheckNo     = querystring.Get("strCheckNo");
            HORep.CheckDate      = querystring.Get("CheckDate");
            HORep.curAmount      = Decimal.TryParse(querystring.Get("curAmount"), out decimalParser) ? decimalParser : 0;
            HORep.strParticulars = querystring.Get("strParticulars");

            UserProfile userprofile = WebCommon.GetUserProfile();

            HORep.intIDSecUser = int.Parse(userprofile.UserId.ToString());

            var HORepDetails = new List <HORep_CVForReplenishmentDetail>();

            string strData1 = formdata[0].ToString().Substring(formdata[0].ToString().IndexOf("],[") + 1, formdata[0].Length - formdata[0].ToString().IndexOf("],[") - 1);

            HORepDetails = (List <HORep_CVForReplenishmentDetail>)HORepDetails.ToClass(strData1);

            DataTable tblHORepDetails = new DataTable();

            tblHORepDetails.TableName = "tblHORepDetails";

            tblHORepDetails.Columns.Add("tblType", typeof(string));
            tblHORepDetails.Columns.Add("intIDtblType", typeof(int));
            tblHORepDetails.Columns.Add("ReferenceNo", typeof(int));
            tblHORepDetails.Columns.Add("intIDPayee", typeof(int));
            tblHORepDetails.Columns.Add("TransactionDate", typeof(DateTime));
            tblHORepDetails.Columns.Add("strCheckNo", typeof(string));
            tblHORepDetails.Columns.Add("curAmount", typeof(decimal));
            tblHORepDetails.Columns.Add("strParticulars", typeof(string));
            tblHORepDetails.Columns.Add("sysReferenceNo", typeof(string));

            foreach (var item in HORepDetails)
            {
                tblHORepDetails.Rows.Add(
                    item.tblType,
                    item.intIDtblType,
                    item.ReferenceNo,
                    item.intIDPayee,
                    item.TransactionDate,
                    item.CheckNo,
                    item.curAmount,
                    item.Particulars,
                    item.sysReferenceNo
                    );
            }

            return(HOReplenishmentDAL.SaveHOReplenishment(HORep, tblHORepDetails));
        }
        public static HORep_ManageResultString SaveHOReplenishment(HORep_CVForReplenishment HORep, DataTable tblHORepDetails)
        {
            var manageResult = new HORep_ManageResultString();

            try
            {
                var dbUtil = new DatabaseManager();
                using (var conn = new SqlConnection(dbUtil.getSQLConnectionString("MainDB")))
                {
                    string result = string.Empty;

                    conn.Open();
                    using (SqlCommand cmd = conn.CreateCommand())
                    {
                        cmd.CommandType    = CommandType.StoredProcedure;
                        cmd.CommandText    = "spDisHORep_SaveHOReplenishment";
                        cmd.CommandTimeout = 180;
                        cmd.Parameters.AddWithValue("@ID", HORep.ID);
                        cmd.Parameters.AddWithValue("@TransactionDate", HORep.TransactionDate);
                        cmd.Parameters.AddWithValue("@intIDMasPayee", HORep.intIDMasPayee);
                        cmd.Parameters.AddWithValue("@intIDMasCOAIndividualSubsidiaryRF", HORep.intIDMasCOAIndividualSubsidiaryRF);
                        cmd.Parameters.AddWithValue("@intIDMasCOAIndividualSubsidiaryCiB", HORep.intIDMasCOAIndividualSubsidiaryCiB);
                        cmd.Parameters.AddWithValue("@strCheckNo", HORep.strCheckNo);
                        cmd.Parameters.AddWithValue("@CheckDate", HORep.CheckDate);
                        cmd.Parameters.AddWithValue("@curAmount", HORep.curAmount);
                        cmd.Parameters.AddWithValue("@strParticulars", HORep.strParticulars);
                        cmd.Parameters.AddWithValue("@intIDSecUser", HORep.intIDSecUser);
                        cmd.Parameters.AddWithValue("@HORep_CVForReplenishmentDetail", tblHORepDetails);
                        result = (string)cmd.ExecuteScalar();
                    }

                    if (result.Contains("Success"))
                    {
                        string[] separators = { "," };
                        string[] words      = result.Split(separators, StringSplitOptions.RemoveEmptyEntries);

                        manageResult.Message = words[0].ToString();
                        manageResult.Code    = words[1].ToString();
                        manageResult.ID      = int.Parse(words[2].ToString());
                    }
                    else
                    {
                        manageResult.Message = result;
                        manageResult.Code    = "";
                        manageResult.ID      = 0;
                    }
                }
            }
            catch (Exception ex)
            {
                manageResult.Message = "Error: " + ex.ToString();
                manageResult.Code    = "";
                manageResult.ID      = 0;
            }

            return(manageResult);
        }
        public static List <HORep_CVForReplenishment> SearchHOReplenishment(string strCriteria)
        {
            DatabaseManager dbUtil = new DatabaseManager();
            var             result = new List <HORep_CVForReplenishment>();

            using (var conn = new SqlConnection(dbUtil.getSQLConnectionString("MainDB")))
            {
                conn.Open();
                using (SqlCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.CommandText = "spDisHORep_SearchHOReplenishment";
                    cmd.Parameters.AddWithValue("@strCriteria", strCriteria);
                    cmd.CommandTimeout = 180;

                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var item = new HORep_CVForReplenishment
                            {
                                ID = ReferenceEquals(reader["ID"], DBNull.Value) ? 0 : int.Parse(reader["ID"].ToString()),
                                TransactionDate = ReferenceEquals(reader["TransactionDate"], DBNull.Value) ? string.Empty : reader["TransactionDate"].ToString(),
                                intIDMasPayee   = ReferenceEquals(reader["intIDMasPayee"], DBNull.Value) ? 0 : int.Parse(reader["intIDMasPayee"].ToString()),
                                strPayeeName    = ReferenceEquals(reader["strPayeeName"], DBNull.Value) ? string.Empty : reader["strPayeeName"].ToString(),
                                intIDMasCOAIndividualSubsidiaryRF  = ReferenceEquals(reader["intIDMasCOAIndividualSubsidiaryRF"], DBNull.Value) ? 0 : int.Parse(reader["intIDMasCOAIndividualSubsidiaryRF"].ToString()),
                                intIDMasCOAIndividualSubsidiaryCiB = ReferenceEquals(reader["intIDMasCOAIndividualSubsidiaryCiB"], DBNull.Value) ? 0 : int.Parse(reader["intIDMasCOAIndividualSubsidiaryCiB"].ToString()),
                                strCheckNo     = ReferenceEquals(reader["strCheckNo"], DBNull.Value) ? string.Empty : reader["strCheckNo"].ToString(),
                                CheckDate      = ReferenceEquals(reader["CheckDate"], DBNull.Value) ? string.Empty : reader["CheckDate"].ToString(),
                                curAmount      = ReferenceEquals(reader["curAmount"], DBNull.Value) ? 0 : decimal.Parse(reader["curAmount"].ToString()),
                                strParticulars = ReferenceEquals(reader["strParticulars"], DBNull.Value) ? string.Empty : reader["strParticulars"].ToString()
                            };

                            result.Add(item);
                        }
                        return(result);
                    }
                }
            }
        }