Exemplo n.º 1
0
 public static bool CheckDouble(string categoryName)
 {
     try
     {
         if (companyId != 0)
         {
             SqlHelper helper = new SqlHelper();
             // DataTable data = helper.CheckDoubleValues(companyId, branchId, "tbl_category", "category_name", useroremail);
             IMS_TESTEntities context = new IMS_TESTEntities();
             var data = context.tbl_category.Any(w => w.category_name == categoryName);
             if (data)
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
     catch (Exception ex)
     {
         ErrorLog.saveerror(ex);
     }
     return(true);
 }
Exemplo n.º 2
0
        public static List <DashboardChartViewModel> GetChartData()
        {
            List <DashboardChartViewModel> list = new List <DashboardChartViewModel>();

            try
            {
                if (HttpContext.Current.Session["company_id"] != null)
                {
                    string           a       = "select top 5 sd.product_id, sum(sd.Quantity),p.product_name from tbl_saledetails sd inner join tbl_sale s on s.sale_id = sd.sale_id inner join tbl_product p on p.product_id = sd.product_id where s.company_id = 1008group by p.product_name, sd.product_id Order by sum(Quantity) desc";
                    IMS_TESTEntities context = new IMS_TESTEntities();
                    list = (from sd in context.tbl_saledetails
                            join p in context.tbl_product on sd.product_id equals p.product_id
                            join s in context.tbl_sale on sd.sale_id equals s.sale_id
                            where s.company_id == companyId
                            group sd by new  { p.product_name, sd.product_id } into g
                            select new DashboardChartViewModel
                    {
                        ProductId = g.Select(f => f.product_id).FirstOrDefault(),
                        ProductName = g.Select(ty => ty.tbl_product.product_name).FirstOrDefault(),
                        Quantity = g.Sum(t3 => t3.quantity).Value
                    }

                            ).Take(10).ToList();


                    return(list);
                }
            }
            catch (Exception ex)
            {
                ErrorLog.saveerror(ex);
            }
            return(list);
        }
Exemplo n.º 3
0
        public static void saveerror(Exception ex)
        {
            IMS_TESTEntities context = new IMS_TESTEntities();
            string           message = "";

            message += Environment.NewLine;
            message += "-----------------------------------------------------------";
            message += Environment.NewLine;
            message += string.Format("Message: {0}", ex.Message);
            message += Environment.NewLine;
            System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(ex, true);
            //Console.WriteLine("Line: " + trace.GetFrame(0).GetFileLineNumber());
            message += string.Format("StackTrace: {0}", trace.GetFrame(0).GetFileLineNumber());
            message += Environment.NewLine;
            message += string.Format("Source: {0}", ex.Source);
            message += Environment.NewLine;
            message += string.Format("TargetSite: {0}", ex.TargetSite.ToString());
            message += Environment.NewLine;
            message += string.Format("Error Url: {0}", ex.ToString());
            message += Environment.NewLine;
            message += "-----------------------------------------------------------";
            message += Environment.NewLine;


            using (SqlConnection con = new SqlConnection(CONNECTION_STRING))
            {
                using (SqlCommand cmd = new System.Data.SqlClient.SqlCommand())
                {
                    cmd.CommandText = "sp_saveerror";
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@company_id", 1);
                    cmd.Parameters.AddWithValue("@branch_id", 1);
                    cmd.Parameters.AddWithValue("@error_type", ex.GetType().Name.ToString());
                    cmd.Parameters.AddWithValue("@error_msg", message.ToString());
                    cmd.Parameters.AddWithValue("@created_by", "Admin");
                    cmd.Parameters.AddWithValue("@created_date", DateTime.Now);
                    con.Open();
                    cmd.Connection = con;
                    cmd.ExecuteNonQuery();
                    con.Close();
                }
            }

            //tbl_error_log tbl_error_log = new tbl_error_log();
            //tbl_error_log.company_id = 1;
            //tbl_error_log.branch_id = 1;
            //tbl_error_log.error_type = ex.GetType().Name.ToString();
            //tbl_error_log.error_msg = message.ToString();
            //tbl_error_log.created_by = "Admin";
            //tbl_error_log.created_date = DateTime.Now;
            //context.tbl_error_log.Add(tbl_error_log);
            //context.SaveChanges();
        }
Exemplo n.º 4
0
        public static List <string> GetPoNumbers(string prefixText, int count)
        {
            IMS_TESTEntities context = new IMS_TESTEntities();


            int year = DateTime.Now.Year;

            prefixText = year.ToString() + "P" + prefixText;
            var           result    = context.tbl_purchase.Where(p => p.InvoiceNumber.Contains(prefixText) && p.company_id == companyId);
            List <string> customers = new List <string>();

            customers = result.Select(p => p.InvoiceNumber).ToList <string>();
            return(customers);
        }
Exemplo n.º 5
0
        public static List <string> GetPoNumbers(string prefixText, int count)
        {
            IMS_TESTEntities context = new IMS_TESTEntities();

            using (SqlConnection conn = new SqlConnection())
            {
                conn.ConnectionString = ConfigurationManager.ConnectionStrings["TestDBConnection"].ConnectionString;
                using (SqlCommand cmd = new SqlCommand())
                {
                    int year = DateTime.Now.Year;
                    prefixText = year.ToString() + "P" + prefixText;
                    var           result    = context.tbl_purchase.Where(p => p.InvoiceNumber.Contains(prefixText) && p.company_id == companyId);
                    List <string> customers = new List <string>();
                    customers = result.Select(p => p.InvoiceNumber).ToList <string>();
                    return(customers);
                }
            }
        }
Exemplo n.º 6
0
        public static string[] ValidateQuantity(decimal enterdQuantity, int productid, int saleId)
        {
            string[] isfail = new string[2];
            isfail[0] = "false";
            isfail[1] = "";
            IMS_TESTEntities context = new IMS_TESTEntities();

            try
            {
                if (enterdQuantity != 0 && productid != 0)
                {
                    if (companyId != 0 && saleId != 0)
                    {
                        SqlHelper helper = new SqlHelper();

                        var returnQuantity = context.GetReturnQuantity(saleId, Constants.Sale, productid, companyId).FirstOrDefault();

                        if (enterdQuantity > returnQuantity)
                        {
                            isfail[0] = "true";
                            isfail[1] = "Only " + returnQuantity + " can be return for the selected product.";
                            return(isfail);
                        }
                    }
                }
                else
                {
                    isfail[0] = "true";
                    isfail[1] = "Please select product or enter correct return quantity.";
                    return(isfail);
                }
                //pass false as default if not true
                isfail[0] = "false";
            }
            catch (Exception ex)
            {
                ErrorLog.saveerror(ex);
            }
            return(isfail);
        }
Exemplo n.º 7
0
        public static string[] ValidateQuantity(decimal enterdQuantity, int productid, int purchaseId)
        {
            string[] isfail = new string[2];
            isfail[0] = "false";
            isfail[1] = "";
            IMS_TESTEntities context = new IMS_TESTEntities();

            // int purchaseId = Convert.ToInt32(hdnPurchaseId.Value);
            try
            {
                if (enterdQuantity != 0 && productid != 0)
                {
                    if (companyId != 0 && purchaseId != 0)
                    {
                        SqlHelper helper        = new SqlHelper();
                        var       stockQuantity = context.tbl_stock.Where(s => s.company_id == companyId && s.product_id == productid).FirstOrDefault();

                        var returnQuantity = context.GetReturnQuantity(purchaseId, Constants.Purchase, productid, companyId).FirstOrDefault();
                        if (enterdQuantity <= returnQuantity)
                        {
                            if (stockQuantity.qty < Convert.ToDecimal(enterdQuantity))
                            {
                                isfail[0] = "true";
                                //lblcheckDoubleError.Visible = true;
                                isfail[1] = "Insufficient stock quantity.";
                                return(isfail);
                            }
                        }
                        else
                        {
                            if (stockQuantity.qty <= returnQuantity)
                            {
                                isfail[0] = "true";
                                //lblcheckDoubleError.Visible = true;
                                isfail[1] = "Only " + stockQuantity.qty + " can be return for the selected product, Since some of item sold.";
                                return(isfail);
                            }
                            else
                            {
                                isfail[0] = "true";
                                //lblcheckDoubleError.Visible = true;
                                isfail[1] = "Only " + returnQuantity + " can be return for the selected product.";
                                return(isfail);
                            }
                        }
                    }
                }
                else
                {
                    isfail[0] = "true";
                    //lblcheckDoubleError.Visible = true;
                    isfail[1] = "Please select product or enter correct return quantity.";
                    return(isfail);
                }

                //pass false as default if not true
                isfail[0] = "false";
            }
            catch (Exception ex)
            {
                ErrorLog.saveerror(ex);
            }
            return(isfail);
        }
Exemplo n.º 8
0
        public static void saveerror(Exception ex)
        {
            IMS_TESTEntities context = new IMS_TESTEntities();
            string           message = "";

            message += Environment.NewLine;
            message += "-----------------------------------------------------------";
            message += Environment.NewLine;
            message += string.Format("Message: {0}", ex.Message);
            message += Environment.NewLine;
            System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(ex, true);
            //Console.WriteLine("Line: " + trace.GetFrame(0).GetFileLineNumber());
            message += string.Format("StackTrace: {0}", trace.GetFrame(0).GetFileLineNumber());
            message += Environment.NewLine;
            message += string.Format("Source: {0}", ex.Source);
            message += Environment.NewLine;
            message += string.Format("TargetSite: {0}", ex.TargetSite.ToString());
            message += Environment.NewLine;
            message += string.Format("Error Url: {0}", ex.ToString());
            message += Environment.NewLine;
            message += "-----------------------------------------------------------";
            message += Environment.NewLine;

            //Code done by afrozz for dropdown and companyid and branch id
            using (SqlConnection con = new SqlConnection(CONNECTION_STRING))
            {
                using (SqlCommand cmd = new System.Data.SqlClient.SqlCommand())
                {
                    var company   = 0;
                    var branch    = 0;
                    var createdby = "Auto Generated";
                    if ((HttpContext.Current.Session["regisFlag"] == null) && (HttpContext.Current.Session["company_id"] != null ||
                                                                               HttpContext.Current.Session["branch_id"] != null || HttpContext.Current.Session["UserID"] != null))
                    {
                        company   = Convert.ToInt32(HttpContext.Current.Session["company_id"]);
                        branch    = Convert.ToInt32(HttpContext.Current.Session["branch_id"]);
                        createdby = HttpContext.Current.Session["UserID"].ToString();
                    }

                    cmd.CommandText = "sp_saveerror";
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@company_id", company);
                    cmd.Parameters.AddWithValue("@branch_id", branch);
                    cmd.Parameters.AddWithValue("@error_type", ex.GetType().Name.ToString());
                    cmd.Parameters.AddWithValue("@error_msg", message.ToString());
                    cmd.Parameters.AddWithValue("@created_by", createdby);
                    cmd.Parameters.AddWithValue("@created_date", DateTime.Now);
                    con.Open();
                    cmd.Connection = con;
                    //cmd.ExecuteNonQuery();

                    Int32 ErrorId = (Int32)cmd.ExecuteScalar();
                    HttpContext.Current.Session["ErrorId"] = null;
                    HttpContext.Current.Session["ErrorId"] = ErrorId;
                    con.Close();
                }
            }

            //tbl_error_log tbl_error_log = new tbl_error_log();
            //tbl_error_log.company_id = 1;
            //tbl_error_log.branch_id = 1;
            //tbl_error_log.error_type = ex.GetType().Name.ToString();
            //tbl_error_log.error_msg = message.ToString();
            //tbl_error_log.created_by = "Admin";
            //tbl_error_log.created_date = DateTime.Now;
            //context.tbl_error_log.Add(tbl_error_log);
            //context.SaveChanges();
        }