Esempio n. 1
0
 public Cari AddNewCariByCariModel(CariModel model)
 {
     try
     {
         var add = new Cari
         {
             IsDeleted   = false,
             Address     = model.Address,
             CreatedById = model.CreatedById,
             CreatedDate = model.CreatedDate,
             Email       = model.Email,
             Company     = model.Company,
             TCNo        = model.TCNo,
             Phone       = model.Phone,
             Title       = model.Title,
             TaxOffice   = model.TaxOffice,
             TaxNumber   = model.TaxNumber,
             Province    = model.Province,
             District    = model.District
         };
         Add(add);
         Commit();
         return(add);
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 2
0
        public ActionResult CariAdd(CariModel cariModel)
        {
            try
            {
                if (Session["User"] == null)
                {
                    return(RedirectToAction("Login", "Account"));
                }
                if (cariModel != null)
                {
                    var user  = (UserModel)Session["User"];
                    var model = new CariModel
                    {
                        Email       = cariModel.Email,
                        CreatedDate = DateTime.Now,
                        CreatedById = user.UserId,
                        IsDeleted   = false,
                        Address     = cariModel.Address,
                        Company     = cariModel.Company,
                        District    = cariModel.District,
                        Phone       = cariModel.Phone,
                        Province    = cariModel.Province,
                        TCNo        = cariModel.TCNo,
                        TaxNumber   = cariModel.TaxNumber,
                        TaxOffice   = cariModel.TaxOffice,
                        Title       = cariModel.Title,
                    };

                    var add = _cariRepository.AddNewCariByCariModel(model);
                    if (add != null)
                    {
                        return(RedirectToAction("CariList", "Cari"));
                    }
                }
                return(View());
            }
            catch (Exception)
            {
                throw;
            }
        }
        public ActionResult GetGorusme(int id)
        {
            string strcon = ConfigurationManager.ConnectionStrings["dbconnection"].ConnectionString;



            List <CariModel> yonetim = new List <CariModel>();

            string sr = @" Select Coalesce(-SUM(D.Miktar*(case when coalesce(S.F2,0)<>0 then S.F2 else S.SatishFiyat end)) ,0)
from INVOICE I,STOK S,INVOICE_DETAIL D WHERE I.CariID=Cari.ID 
AND I.ID=D.faturaID AND S.ID=D.UrunID ";

            if (AyarMetot.ProTerminal != "Simge")
            {
                sr = "0";
            }

            string SorguFirmaID = Session["FirmaID"].ToString();
            string sorg         = "";

            if (id == 0)
            {
                sorg =
                    @"Select Telefon1,GSM,EPosta,alacakB,borcB,Milleti,FirmaKodu,CariUnvan,Cari.ID,CariGrubu,Coalesce( alacakB-borcB,0)  as [Bakiye],
(" + sr + @") as [SatisF2], KTipi,Cari.paraBirimi as PB from Cari INNER JOIN BALANCE ON cariID=Cari.ID and Balance.paraBirimi=Cari.paraBirimi Where Cari.KTipi <> N'BAYİİ' and Cari.FirmaID=" + SorguFirmaID + " order by CariUnvan";
            }
            else if (id == 1)
            {
                sorg =
                    @"Select Telefon1,GSM,EPosta,alacakB,borcB,Milleti,FirmaKodu,CariUnvan,Cari.ID,CariGrubu,Coalesce( alacakB-borcB,0)  as [Bakiye],
(0) as [SatisF2], KTipi,Cari.paraBirimi as PB from Cari INNER JOIN BALANCE ON cariID=Cari.ID and Balance.paraBirimi=Cari.paraBirimi where Cari.KTipi=N'BAYİİ' and Cari.FirmaID=" + SorguFirmaID + " order by CariUnvan ";
            }

            string sorg2 = @"SELECT CariUnvan,alacakB,borcB FROM Cari K, BALANCE Y WHERE K.ID = Y.cariID";

            using (SqlConnection con = new SqlConnection(strcon))
            {
                con.Open();
                using (SqlCommand carigetir = new SqlCommand(sorg, con))
                {
                    using (SqlDataReader dr = carigetir.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            CariModel yt = new CariModel();

                            yt.Alacak = Convert.ToDecimal(dr["alacakB"]);
                            yt.Borc   = Convert.ToDecimal(dr["borcB"]);

                            var alacaklar = yt.Alacak - yt.Borc;

                            if (alacaklar < 0)
                            {
                                yt.SonDurum = "(B)";
                                int    uzunluk = dr["Bakiye"].ToString().Length;
                                string sub     = dr["Bakiye"].ToString().Substring(1, uzunluk - 1);
                                yt.Bakiye = Convert.ToDecimal(sub);
                            }
                            else if (alacaklar > 0)
                            {
                                yt.SonDurum = "(A)";
                                yt.Bakiye   = Convert.ToDecimal(dr["Bakiye"]);
                            }
                            else
                            {
                                yt.SonDurum = "(-)";
                                yt.Bakiye   = Convert.ToDecimal(dr["Bakiye"]);
                            }

                            yt.Iletisim = dr["Telefon1"].ToString();
                            if (dr["GSM"].ToString() != "")
                            {
                                yt.Iletisim = yt.Iletisim + "  " + dr["GSM"].ToString();
                                yt.Iletisim = yt.Iletisim.TrimStart().TrimEnd();
                            }
                            yt.EPosta    = dr["EPosta"].ToString();
                            yt.FirmaKodu = dr["FirmaKodu"].ToString();
                            yt.CariUnvan = dr["CariUnvan"].ToString();
                            yt.KTipi     = dr["KTipi"].ToString();
                            yt.ID        = Convert.ToInt32(dr["ID"]);

                            yt.SatisF2    = Convert.ToDecimal(dr["SatisF2"]);
                            yt.CariGrubu  = dr["CariGrubu"].ToString();
                            yt.paraBirimi = dr["PB"].ToString();

                            yonetim.Add(yt);
                        }
                    }
                }
            }



            return(Json(new { data = yonetim.Distinct() }, JsonRequestBehavior.AllowGet));
        }