Example #1
0
        private void btn_product_Click(object sender, RoutedEventArgs e)
        {
            var sendMaster   = new stp_inv_goods_send_selResult();
            var sendArticles = new List <stp_inv_goods_send_article_selResult>();
            var storesList   = new BLL <stp_inv_store_selResult>().GetAllRecords_DB();
            var partsStore   = storesList.FindLast(store => store.inv_store_name.Contains("اولیه"));

            if (partsStore == null && storesList.Count > 0)
            {
                partsStore = storesList[0];
            }
            sendMaster.inv_goods_send_inv_store_id            = partsStore.inv_store_id;
            sendMaster.inv_goods_send_inv_store_name          = partsStore.inv_store_name;
            sendMaster.inv_goods_send_inv_store_code          = partsStore.inv_store_code;
            sendMaster.inv_goods_send_description             = "حواله مواد اولیه بر اساس رسید محصول - شمارۀ سریال رسید : " + selectedRecord.inv_goods_receive_no;
            sendMaster.inv_goods_send_send_type_glb_coding_id = (long)SendType.DeliverToProduction;
            var detailsList = new BLL <stp_acc_detail_selResult>().GetSomeRecords_DB
                              (
                new stp_acc_detail_selResult()
            {
                acc_detail_id = selectedRecord.inv_goods_receive_destination_acc_detail_id
            }
                              );

            if (detailsList.Count == 0)
            {
                Messages.ErrorMessage("طرف سند را مشخص کنید");
                return;
            }
            var destinationDetail = detailsList[0];

            sendMaster.inv_goods_send_destination_acc_detail_id   = destinationDetail.acc_detail_id;
            sendMaster.inv_goods_send_destination_acc_detail_code = destinationDetail.acc_detail_code;
            sendMaster.inv_goods_send_destination_acc_detail_name = destinationDetail.acc_detail_name;
            foreach (stp_inv_goods_receive_article_selResult productRA in bindingListArticle)
            {
                var partsList = new BLL <stp_inv_product_part_selResult>().
                                GetSomeRecords_DB(new stp_inv_product_part_selResult()
                {
                    inv_product_part_product_inv_group_goods_id = productRA.inv_goods_receive_article_inv_group_goods_id
                });

                foreach (stp_inv_product_part_selResult partFormula in partsList)
                {
                    var sendArticle   = new stp_inv_goods_send_article_selResult();
                    var convertResult = new stp_inv_convert_count_from_measure1_to_measure2Result
                    {
                        inv_goods_id    = productRA.inv_goods_receive_article_inv_group_goods_id,
                        count1          = productRA.inv_goods_receive_article_count,
                        glb_measure_id1 = productRA.inv_goods_receive_article_glb_measure_id,
                        glb_measure_id2 = partFormula.inv_product_part_product_glb_measure_id
                    };

                    convertResult = new BLL <stp_inv_convert_count_from_measure1_to_measure2Result>().GetOneRecord(convertResult);
                    if (convertResult == null || convertResult.count2 == null)
                    {
                        Messages.ErrorMessage("بروز خطا هنگام محاسبۀ تعداد کالای " + partFormula.inv_product_part_part_inv_group_goods_name);
                        continue;
                    }
                    var resultCount = convertResult.count2;
                    sendArticle.inv_goods_send_article_count                = resultCount.Value * partFormula.inv_product_part_formula;
                    sendArticle.inv_goods_send_article_glb_measure_id       = partFormula.inv_product_part_part_glb_measure_id;
                    sendArticle.inv_goods_send_article_glb_measure_name     = partFormula.inv_product_part_part_glb_measure_name;
                    sendArticle.inv_goods_send_article_inv_group_goods_id   = partFormula.inv_product_part_part_inv_group_goods_id;
                    sendArticle.inv_goods_send_article_inv_group_goods_name = partFormula.inv_product_part_part_inv_group_goods_name;
                    sendArticle.inv_goods_send_article_inv_group_goods_code = partFormula.inv_product_part_part_inv_group_goods_code;
                    sendArticle.inv_goods_send_article_description          = "کالای تشکیل دهندۀ محصول " + partFormula.inv_product_part_product_inv_group_goods_name;
                    sendArticle.inv_goods_send_article_count_measure        = sendArticle.inv_goods_send_article_count + " " + sendArticle.inv_goods_send_article_glb_measure_name;
                    sendArticles.Add(sendArticle);
                }
            }
            if (sendArticles.Count > 0)
            {
                new frm_inv_goods_send().CreateDocument(sendMaster, sendArticles);
            }
            else
            {
                Messages.InformationMessage("کالاهای این رسید محصول نیستند");
            }
        }
Example #2
0
        private void APMToolbarButton_Click(object sender, RoutedEventArgs e)
        {
            string           DescriptionSend, DescriptionReceive;
            MessageBoxResult result = new MessageBoxResult();

            ////در صورتی که این سند انبار گردانی تعدیل شده باشد پیغام می دهد
            if (selectedRecord.inv_physical_counting_have_adjustment == true)
            {
                result = Messages.QuestionMessage_YesNo(" این سند انبار گردانی دارای سند تعدیل می باشد آیا  می خواهید مجدداً سند تعدیل صادر شود");
            }
            if (result == MessageBoxResult.No || result == MessageBoxResult.Cancel)
            {
                return;
            }
            /////
            List <stp_inv_goods_send_article_selResult>    ArticleListForSendForm    = new List <stp_inv_goods_send_article_selResult>();
            List <stp_inv_goods_receive_article_selResult> ArticleListForReceiveForm = new List <stp_inv_goods_receive_article_selResult>();
            /////
            stp_inv_goods_send_selResult    SendRecord    = new stp_inv_goods_send_selResult();
            stp_inv_goods_receive_selResult ReceiveRecord = new stp_inv_goods_receive_selResult();
            /////جهت به دست آوردن طرف سند انبار
            stp_inv_store_selResult store = new stp_inv_store_selResult();

            store.inv_store_id = selectedRecord.inv_physical_counting_inv_store_id;
            store           = new BLL <stp_inv_store_selResult>().GetOneRecord(store);
            DescriptionSend = "سند تعدیل کاهشی مربوط به سند انبار گردانی" + " " + selectedRecord.inv_physical_counting_code;
            SendRecord.inv_goods_send_inv_store_id            = selectedRecord.inv_physical_counting_inv_store_id;
            SendRecord.inv_goods_send_type_glb_coding_name    = SendType.Adjustment.ToString();
            SendRecord.inv_goods_send_send_type_glb_coding_id = (long)SendType.Adjustment;
            SendRecord.inv_goods_send_date                        = APMDateTime.Today;
            SendRecord.inv_goods_send_inv_store_id                = selectedRecord.inv_physical_counting_inv_store_id;
            SendRecord.inv_goods_send_inv_store_name              = selectedRecord.inv_physical_counting_inv_store_name;
            SendRecord.inv_goods_send_inv_store_code              = selectedRecord.inv_physical_counting_inv_store_code;
            SendRecord.inv_goods_send_description                 = DescriptionSend;
            SendRecord.inv_goods_send_destination_acc_detail_id   = (long)store.inv_store_glb_personel_acc_detail_id;
            SendRecord.inv_goods_send_destination_acc_detail_code = store.inv_store_glb_personel_code;
            SendRecord.inv_goods_send_destination_acc_detail_name = store.inv_store_glb_personel_name;
            ////
            ////
            DescriptionReceive = "سند تعدیل افزایشی مربوط به سند انبار گردانی" + " " + selectedRecord.inv_physical_counting_code;
            ReceiveRecord.inv_goods_receive_inv_store_id               = selectedRecord.inv_physical_counting_inv_store_id;
            ReceiveRecord.inv_goods_receive_type_glb_coding_name       = ReceiveType.Adjustment.ToString();
            ReceiveRecord.inv_goods_receive_receive_type_glb_coding_id = (long)ReceiveType.Adjustment;
            ReceiveRecord.inv_goods_receive_date                        = APMDateTime.Today;
            ReceiveRecord.inv_goods_receive_inv_store_id                = selectedRecord.inv_physical_counting_inv_store_id;
            ReceiveRecord.inv_goods_receive_inv_store_name              = selectedRecord.inv_physical_counting_inv_store_name;
            ReceiveRecord.inv_goods_receive_inv_store_code              = selectedRecord.inv_physical_counting_inv_store_code;
            ReceiveRecord.inv_goods_receive_description                 = DescriptionReceive;
            ReceiveRecord.inv_goods_receive_destination_acc_detail_id   = (long)store.inv_store_glb_personel_acc_detail_id;;
            ReceiveRecord.inv_goods_receive_destination_acc_detail_code = store.inv_store_glb_personel_code;
            ReceiveRecord.inv_goods_receive_destination_acc_detail_name = store.inv_store_glb_personel_name;
            ////
            foreach (stp_inv_physical_counting_article_selResult article in bindingListArticle)
            {
                if (article.inv_physical_counting_article_shortage != 0 && article.inv_physical_counting_article_shortage != null)
                {
                    stp_inv_goods_send_article_selResult Senditem = new stp_inv_goods_send_article_selResult();
                    Senditem.inv_goods_send_article_inv_group_goods_id   = article.inv_physical_counting_article_inv_group_goods_id;
                    Senditem.inv_goods_send_article_inv_group_goods_name = article.inv_physical_counting_article_inv_group_goods_name;
                    Senditem.inv_goods_send_article_inv_group_goods_code = article.inv_physical_counting_article_inv_group_goods_code;
                    Senditem.inv_goods_send_article_count          = System.Convert.ToDouble(article.inv_physical_counting_article_shortage);
                    Senditem.inv_goods_send_article_glb_measure_id = article.inv_physical_counting_article_glb_measure_id;
                    Senditem.inv_goods_send_article_count_measure  = Senditem.inv_goods_send_article_count + article.inv_physical_counting_article_glb_measure_name;
                    Senditem.inv_goods_send_article_description    = DescriptionSend;
                    ArticleListForSendForm.Add(Senditem);
                }

                else
                if (article.inv_physical_counting_article_surplus != 0 && article.inv_physical_counting_article_surplus != null)
                {
                    stp_inv_goods_receive_article_selResult Receiveitem = new stp_inv_goods_receive_article_selResult();
                    Receiveitem.inv_goods_receive_article_inv_group_goods_id   = article.inv_physical_counting_article_inv_group_goods_id;
                    Receiveitem.inv_goods_receive_article_inv_group_goods_name = article.inv_physical_counting_article_inv_group_goods_name;
                    Receiveitem.inv_goods_receive_article_inv_group_goods_code = article.inv_physical_counting_article_inv_group_goods_code;
                    Receiveitem.inv_goods_receive_article_glb_measure_id       = article.inv_physical_counting_article_glb_measure_id;
                    Receiveitem.inv_goods_receive_article_count         = System.Convert.ToDouble(article.inv_physical_counting_article_surplus);
                    Receiveitem.inv_goods_receive_article_count_measure = Receiveitem.inv_goods_receive_article_count + article.inv_physical_counting_article_glb_measure_name;
                    Receiveitem.inv_goods_receive_article_description   = DescriptionReceive;
                    ArticleListForReceiveForm.Add(Receiveitem);
                }
            }
            if (ArticleListForSendForm.Count != 0)
            {
                frm_inv_goods_send AdjustmentSendForm = new frm_inv_goods_send();
                AdjustmentSendForm.CreateDocument(SendRecord, ArticleListForSendForm);
            }

            if (ArticleListForReceiveForm.Count != 0)
            {
                frm_inv_goods_receive AdjustmentReceiveForm = new frm_inv_goods_receive();
                AdjustmentReceiveForm.CreateDocument(ReceiveRecord, ArticleListForReceiveForm);
            }
            RefreshClick();
        }