Esempio n. 1
0
        public HttpResponseMessage Put(int id, [FromBody] Declar declar)
        {
            try
            {
                using (loandbEntities entities = new loandbEntities())
                {
                    var entity = entities.Declars.FirstOrDefault(e => e.P_ID == id);
                    if (entity == null)
                    {
                        return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Person with P_Id " + id.ToString() + " Not Found!"));
                    }
                    else
                    {
                        entity.ID            = entity.ID;
                        entity.P_ID          = entity.P_ID;
                        entity.Dec_Place     = declar.Dec_Place;
                        entity.Dec_Date      = declar.Dec_Date;
                        entity.Dec_App_Photo = declar.Dec_App_Photo;
                        entity.Dec_App_Sign  = declar.Dec_App_Sign;


                        entities.SaveChanges();

                        return(Request.CreateResponse(HttpStatusCode.OK));
                    }
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }
Esempio n. 2
0
        public HttpResponseMessage Post([FromBody] Declar declar)
        {
            try
            {
                using (loandbEntities entities = new loandbEntities())
                {
                    entities.Configuration.ProxyCreationEnabled = false;
                    entities.Declars.Add(declar);
                    entities.SaveChanges();

                    var message = Request.CreateResponse(HttpStatusCode.Created, declar);
                    message.Headers.Location = new Uri(Request.RequestUri + declar.ID.ToString());
                    return(message);
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }
Esempio n. 3
0
        protected override void Add()
        {
            Dictionary <string, string> declar = new Dictionary <string, string>();
            Declar d = new Declar(model,
                                  context.GetPokupki(Month, Year),
                                  context.GetProdazbi(Month, Year));

            var firma = ConfigTempoSinglenton.GetInstance().CurrentFirma;

            declar.Add("data", DateTime.Now.ToShortDateString());
            declar.Add("firma", firma.Name);
            declar.Add("adress", firma.Address);
            declar.Add("tel", firma.Tel);
            declar.Add("dds", firma.DDSnum);
            declar.Add("iddds", firma.Bulstad);
            declar.Add("kl01", d.Kl01.ToString(Vf.LevFormatUI));
            declar.Add("kl11", d.Kl11.ToString(Vf.LevFormatUI));
            declar.Add("kl12", d.Kl12.ToString(Vf.LevFormatUI));
            declar.Add("kl13", d.Kl13.ToString(Vf.LevFormatUI));
            declar.Add("kl14", d.Kl14.ToString(Vf.LevFormatUI));
            declar.Add("kl15", d.Kl15.ToString(Vf.LevFormatUI));
            declar.Add("kl16", d.Kl16.ToString(Vf.LevFormatUI));
            declar.Add("kl17", d.Kl17.ToString(Vf.LevFormatUI));
            declar.Add("kl18", d.Kl18.ToString(Vf.LevFormatUI));
            declar.Add("kl19", d.Kl19.ToString(Vf.LevFormatUI));

            declar.Add("kl20", d.Kl20.ToString(Vf.LevFormatUI));
            declar.Add("kl21", d.Kl12.ToString(Vf.LevFormatUI));
            declar.Add("kl22", d.Kl22.ToString(Vf.LevFormatUI));
            declar.Add("kl23", d.Kl23.ToString(Vf.LevFormatUI));
            declar.Add("kl24", d.Kl24.ToString(Vf.LevFormatUI));

            declar.Add("kl30", d.Kl30.ToString(Vf.LevFormatUI));
            declar.Add("kl31", d.Kl31.ToString(Vf.LevFormatUI));
            declar.Add("kl32", d.Kl32.ToString(Vf.LevFormatUI));
            declar.Add("kl33", d.Kl33.ToString(Vf.LevFormatUI));

            declar.Add("kl40", d.Kl40.ToString(Vf.LevFormatUI));
            declar.Add("kl41", d.Kl41.ToString(Vf.LevFormatUI));
            declar.Add("kl42", d.Kl40.ToString(Vf.LevFormatUI));
            declar.Add("kl43", d.Kl41.ToString(Vf.LevFormatUI));

            declar.Add("kl50", d.Kl50.ToString(Vf.LevFormatUI));
            declar.Add("kl60", d.Kl60.ToString(Vf.LevFormatUI));
            declar.Add("kl70", d.Kl70.ToString(Vf.LevFormatUI));
            declar.Add("kl71", d.Kl71.ToString(Vf.LevFormatUI));

            declar.Add("kl80", d.Kl80.ToString(Vf.LevFormatUI));
            declar.Add("kl81", d.Kl81.ToString(Vf.LevFormatUI));
            declar.Add("kl82", d.Kl82.ToString(Vf.LevFormatUI));

            declar.Add("DateTimeNow", DateTime.Now.ToShortDateString());
            string expected = string.Empty; // TODO: Initialize to an appropriate value
            string actual;

            actual = DeklarviewModel.ReturnDeklar(declar);
            var path = AppDomain.CurrentDomain.BaseDirectory + "Deklar1.txt";

            using (StreamWriter sw = new StreamWriter(path))
            {
                sw.Write(actual);
            }
            Process.Start(path);
        }
Esempio n. 4
0
        protected override void AddNew()
        {
            Declar d = new Declar(model,
                                  context.GetPokupki(Month, Year),
                                  context.GetProdazbi(Month, Year));

            var           firma = ConfigTempoSinglenton.GetInstance().CurrentFirma;
            StringBuilder sb    = new StringBuilder();

            sb.AppendFormat("{0,-15}", firma.DDSnum);   //1
            sb.AppendFormat("{0,-50}", firma.NameBoss); //2
            sb.AppendFormat("{0,-4}", Year);            //3
            sb.AppendFormat("{0,-2}", Month);           //3
            sb.AppendFormat("{0,-50}", firma.Names);    //4
            sb.AppendFormat("{0,-15}", 1);              //5 ?
            sb.AppendFormat("{0,-15}", 1);              //6 ?
            sb.AppendFormat("{0,-15}", d.Kl01);         //7
            sb.AppendFormat("{0,-15}", d.Kl20);         //8
            sb.AppendFormat("{0,-15}", d.Kl11);         //9
            sb.AppendFormat("{0,-15}", d.Kl21);         //10
            sb.AppendFormat("{0,-15}", d.Kl12);         //11
            sb.AppendFormat("{0,-15}", d.Kl22);         //12
            sb.AppendFormat("{0,-15}", d.Kl23);         //13
            sb.AppendFormat("{0,-15}", d.Kl13);         //14
            sb.AppendFormat("{0,-15}", d.Kl24);         //15
            sb.AppendFormat("{0,-15}", d.Kl14);         //16
            sb.AppendFormat("{0,-15}", d.Kl15);         //17
            sb.AppendFormat("{0,-15}", d.Kl16);         //18
            sb.AppendFormat("{0,-15}", d.Kl17);         //19
            sb.AppendFormat("{0,-15}", d.Kl18);         //20
            sb.AppendFormat("{0,-15}", d.Kl19);         //21
            //pokupki
            sb.AppendFormat("{0,-15}", d.Kl30);         //22
            sb.AppendFormat("{0,-15}", d.Kl31);         //23
            sb.AppendFormat("{0,-15}", d.Kl41);         //24
            sb.AppendFormat("{0,-15}", d.Kl32);         //25
            sb.AppendFormat("{0,-15}", d.Kl42);         //26
            sb.AppendFormat("{0,-15}", d.Kl43);         //27
            //resultat
            sb.AppendFormat("{0,-15}", d.Kl33);         //28
            sb.AppendFormat("{0,-15}", d.Kl40);         //29
            sb.AppendFormat("{0,-15}", d.Kl50);         //30
            sb.AppendFormat("{0,-15}", d.Kl60);         //31
            sb.AppendFormat("{0,-15}", d.Kl70);         //32
            sb.AppendFormat("{0,-15}", d.Kl71);         //33
            sb.AppendFormat("{0,-15}", d.Kl80);         //34
            sb.AppendFormat("{0,-15}", d.Kl81);         //35
            sb.AppendFormat("{0,-15}", d.Kl81);         //36

            var      path = AppDomain.CurrentDomain.BaseDirectory + "Deklar.txt";
            Encoding srcEncodingFormat = Encoding.UTF8;
            Encoding dstEncodingFormat = Encoding.GetEncoding("windows-1251");

            byte [] originalByteString  = srcEncodingFormat.GetBytes(sb.ToString());
            byte [] convertedByteString = Encoding.Convert(srcEncodingFormat, dstEncodingFormat, originalByteString);
            string  finalString         = dstEncodingFormat.GetString(convertedByteString);

            using (StreamWriter sw = new StreamWriter(path))
            {
                sw.Write(finalString);
            }
            Process.Start(path);
        }