Exemplo n.º 1
0
        public int SaveOrder(string CompanyId, string GrandTotal, string Discount, string Payment, string Arrears, string Comments, DateTime DeliveryDate, DataTable OrderDetail, bool IsReturn)
        {
            int newId = 0;
            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    if (OrderDetail != null && OrderDetail.Rows.Count > 0)
                    {

                        DataAccessManager dam = new DataAccessManager();
                        string[,] paramArray = {
                                       {"@CompanyId", CompanyId },
                                       {"@GrandTotal", GrandTotal },
                                       {"@Discount", Discount },
                                       {"@Payment", Payment },
                                       {"@Arrears", Arrears},
                                       {"@Comments", Comments},
                                       {"@DeliveryDate", Common.FormateDateForDB(DeliveryDate)},
                                       {"@Status", "1"}

                                       };
                        int id = Convert.ToInt32(dam.ExecuteScalar(CommandType.StoredProcedure, "InsertUpdateDeleteOrder", paramArray));
                        if (id > 0)
                        {
                            foreach (DataRow row in OrderDetail.Rows)
                            {
                                SaveOrderDetail(id.ToString(),
                                     Convert.ToString(row["ItemId"])
                                    , Convert.ToString(row["PurchasePrice"])
                                    , Convert.ToString(row["Quantity"])
                                    , Convert.ToString(row["Total"])
                                    , Convert.ToString(row["Discount"])
                                    , Convert.ToString(row["GrandTotal"])
                                    );
                            }
                            scope.Complete();
                            newId = id;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return newId;
        }
Exemplo n.º 2
0
        public long MakePayment(string CompanyId, string datetime, string amount, string Comments)
        {
            long TransactionId = -1;
            try
            {
                DataAccessManager dam = new DataAccessManager();
                string[,] paramArray = {
                {"@CustomerCompanyId", CompanyId},
                {"@TransactionDate", datetime},
                {"@Amount", amount},
                {"@IsCustomer", "1"},
                {"@UserId", Common.CURRENT_USER.Id.ToString()},
                {"@Comments", Comments}

               };
                object obj= dam.ExecuteScalar(CommandType.StoredProcedure, "InsertUpdateDeleteTransaction", paramArray);
                TransactionId = Convert.ToInt64(obj);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return TransactionId;
        }
Exemplo n.º 3
0
 public static bool VerifyRegistration()
 {
     bool IsValid = false;
     try
     {
         DataAccessManager dam = new DataAccessManager();
         object val = dam.ExecuteScalar(CommandType.Text, "SELECT top 1 [AD97DC5D7E618288E63528CC5CC6F3AE] from Shop");
         if (val != null)
         {
             string strVal = Convert.ToString(val);
             string newKey = CreateUniqueKey();
             IsValid = strVal == newKey;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     return IsValid;
 }
Exemplo n.º 4
0
        public static bool VerifyLastRun()
        {
            bool result = false;
            try
            {
                DateTime LRDate = DateTime.MinValue;
                DataAccessManager dam = new DataAccessManager();
                object val = dam.ExecuteScalar(CommandType.Text, "SELECT top 1 [A34C0CEC63EC0F1739FB5CB8F43A9CE1] from Shop");
                if (val != null)
                {
                    string strVal = Convert.ToString(val);
                    strVal = Decrypt(strVal, pass);
                    LRDate = Convert.ToDateTime(strVal, CultureInfo.InvariantCulture);
                    DateTime dtNow = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, CultureInfo.InvariantCulture.Calendar);

                    result = LRDate < DateTime.Now.AddMinutes(5);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return result;
        }
Exemplo n.º 5
0
 public static bool RegistrationExists()
 {
     bool Exists = true;
     try
     {
         DataAccessManager dam = new DataAccessManager();
         object val = dam.ExecuteScalar(CommandType.Text, "SELECT count(*) as cnt from Shop");
         if (val == null || Convert.ToInt32(val) == 0)
             Exists = false;
     }
     catch (Exception ex)
     {
     }
     return Exists;
 }
Exemplo n.º 6
0
        public static int NoOfRegisteredDaysLeft()
        {
            int days = 0;
            try
            {
                DateTime xpDate = DateTime.MinValue;
                DataAccessManager dam = new DataAccessManager();
                object val = dam.ExecuteScalar(CommandType.Text, "SELECT top 1 [1B29BA78A2DF965545C5A563B6E997AE] from Shop");
                if (val != null)
                {
                    string strVal = Convert.ToString(val);
                    strVal = Decrypt(strVal, pass);
                    xpDate = Convert.ToDateTime(strVal, CultureInfo.InvariantCulture);
                    DateTime dtNow = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, CultureInfo.InvariantCulture.Calendar);
                    TimeSpan ts = new TimeSpan(xpDate.Ticks - dtNow.Date.Ticks);
                    days = ts.Days;

                    CultureInfo cInfo = CultureInfo.InvariantCulture;
                }
            }
            catch (Exception ex)
            {

                throw;
            }
            return days;
        }
Exemplo n.º 7
0
        public static long NoOfCodeExists(string code, Modules Table)
        {
            string[,] paramArray = {
                                        {"@Code",code},
                                        {"@TableName",Table.ToString()},
                                        {"@Active","0"}

                                   };
            DataAccessManager dam = new DataAccessManager();
            return Convert.ToInt64(dam.ExecuteScalar(CommandType.StoredProcedure, "IsCodeExists", paramArray));
        }
Exemplo n.º 8
0
 public static long GetNextId(Modules Table)
 {
     string[,] paramArray = { { "@TableName", Table.ToString() } };
     DataAccessManager dam = new DataAccessManager();
     return Convert.ToInt64(dam.ExecuteScalar(CommandType.StoredProcedure, "GetNextId", paramArray));
 }
Exemplo n.º 9
0
        public bool IsDuplictaeInvoiceNo(string InvoiceNo, string CompanyId)
        {
            short count = 0;
            try
            {
                DataAccessManager dam = new DataAccessManager();
                string[,] paramArray = {
                                       {"@InvoiceNo", InvoiceNo},
                                       {"@CompanyId", CompanyId}};
                object obj = dam.ExecuteScalar(CommandType.StoredProcedure, "IsDuplictaeInvoiceNo", paramArray);
                if (obj != null)
                    count = Convert.ToInt16(obj);
                //count = Convert.ToInt16(dam.ExecuteScalar(CommandType.StoredProcedure, "IsDuplictaeInvoiceNo", paramArray));
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return count>0;
        }
Exemplo n.º 10
0
        public long SaveReceipt(
            string CustomerId,
            string GrandTotal,
            string TotalDiscount,
            string NetTotal,
            string Payment,
            string Arrears,
            string Comments,
string Purpose,

            DataTable ReceiptDetail,
            bool IsReturn, string PrevReceiptId)
        {
            long newId = 0;
            if (!IsReturn)
                PrevReceiptId = "0";

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    long Id = 0;
                    if (ReceiptDetail != null && ReceiptDetail.Rows.Count > 0)
                    {
                        DataAccessManager dam = new DataAccessManager();
                        string[,] paramArray = {
                                       {"@CustomerId", CustomerId },
                                       {"@GrandTotal", string.IsNullOrEmpty(GrandTotal)?"0":GrandTotal  },
                                       {"@Discount", string.IsNullOrEmpty(TotalDiscount)?"0":TotalDiscount },
                                       {"@Total", string.IsNullOrEmpty(NetTotal)?"0":NetTotal  },
                                       {"@Payment", string.IsNullOrEmpty(Payment)?"0":Payment  },
                                       {"@Arearrs", string.IsNullOrEmpty(Arrears)?"0":Arrears  },
                                       {"@Comments", Comments },
                                       {"@Purpose", Purpose},
                                       {"@UserId", Common.CURRENT_USER.Id.ToString()},
                                       {"@IsReturn", IsReturn?"1":"0"}

                                       };
                        Id = Convert.ToInt64(dam.ExecuteScalar(CommandType.StoredProcedure, "InsertUpdateDeleteReceipt", paramArray));
                        if (Id > 0)
                        {
                            foreach (DataRow row in ReceiptDetail.Rows)
                            {
                                SaveReceiptDetail(
                                    Id.ToString(),
                                    Convert.ToString(row["ItemId"])
                                    , Convert.ToString(row["SalePrice"])
                                    , Convert.ToString(row["Quantity"])
                                    , Convert.ToString(row["GrandTotal"])
                                    , Convert.ToString(row["Discount"])
                                    , Convert.ToString(row["Total"])
                                    , Convert.ToString(row["ItemDiscount"])
                                    , IsReturn
                                     ,PrevReceiptId
                                    );
                            }

                            SetReceiptProfitLoss(Id);
                            scope.Complete();
                            newId = Id;
                        }
                    }

                }
            }
            catch (Exception ex)
            {
                ExceptionLog.LogException(Modules.Item, "SaveReceipt", ex, "Item Exception");
            }

            return newId;
        }
Exemplo n.º 11
0
        public long SaveInvoice(string CompanyId,string InvoiceNo, string GrandTotal, string Discount, string Payment, string Arrears, string Comments, string OrderNo, DataTable InvoiceDetail, bool IsReturn)
        {
            long newId = 0;

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    if (InvoiceDetail != null && InvoiceDetail.Rows.Count > 0)
                    {
                        long Id = 0;
                        DataAccessManager dam = new DataAccessManager();
                        string[,] paramArray = {
                                       {"@CompanyId", CompanyId },
                                       {"@InvoiceNo", InvoiceNo },
                                       {"@GrandTotal", string.IsNullOrEmpty(GrandTotal)?"0":GrandTotal },
                                       {"@Discount", string.IsNullOrEmpty(Discount)?"0":Discount },
                                       {"@Payment", string.IsNullOrEmpty(Payment)?"0":Payment },
                                       {"@Arrears", string.IsNullOrEmpty(Arrears)?"0":Arrears},
                                       {"@Comments", Comments},
                                       {"@OrderNo", OrderNo},
                                       {"@UserId", Common.CURRENT_USER.Id.ToString()},
                                       {"@IsReturn", IsReturn?"1":"0"}
                                       };
                        Id = Convert.ToInt64(dam.ExecuteScalar(CommandType.StoredProcedure, "InsertUpdateDeleteInvoice", paramArray));
                        if (Id > 0)
                        {
                            foreach (DataRow row in InvoiceDetail.Rows)
                            {
                                SaveInvoiceDetail(Id.ToString(), Convert.ToString(row["ItemId"])
                                    , Convert.ToString(row["BatchNo"])
                                    , Convert.ToString(row["ExpiryDate"])
                                    , Convert.ToString(row["SalePrice"])
                                    , Convert.ToString(row["PurchasePrice"])
                                    , Convert.ToString(row["Quantity"])
                                    , Convert.ToString(row["Total"])
                                    , Convert.ToString(row["Discount"])
                                    , Convert.ToString(row["GrandTotal"])
                                    , IsReturn
                                    );
                            }
                            scope.Complete();
                            newId = Id;
                        }

                    }
                }

            return newId;
        }